Fire Bolt implemented.

pull/28/head
sigonasr2 1 year ago
parent 78b6113d8e
commit 3939ee5693
  1. 8
      Crawler/BulletTypes.h
  2. 3
      Crawler/Class.cpp
  3. 3
      Crawler/Crawler.vcxproj
  4. 9
      Crawler/Crawler.vcxproj.filters
  5. 4
      Crawler/Effect.cpp
  6. 5
      Crawler/EnergyBolt.cpp
  7. 43
      Crawler/FireBolt.cpp
  8. 9
      Crawler/Monster.cpp
  9. 2
      Crawler/Version.h
  10. 25
      Crawler/assets/Campaigns/1_1_test.tmx
  11. 5
      Crawler/utils.cpp
  12. 6
      Crawler/utils.h

@ -7,4 +7,12 @@ struct EnergyBolt:public Bullet{
void Update(float fElapsedTime)override;
bool PlayerHit(Player&player)override;
bool MonsterHit(Monster&monster)override;
};
struct FireBolt:public Bullet{
float lastParticleSpawn=0;
FireBolt(vf2d pos,vf2d vel,float radius,int damage,bool friendly=false,Pixel col=WHITE);
void Update(float fElapsedTime)override;
bool PlayerHit(Player&player)override;
bool MonsterHit(Monster&monster)override;
};

@ -288,6 +288,9 @@ bool Wizard::AutoAttack(){
}
bool Wizard::Ability1(){
ACCESS_PLAYER
float angleToCursor=atan2(game->GetWorldMousePos().y-p.pos.y,game->GetWorldMousePos().x-p.pos.x);
PLAYER_BULLET_LIST.push_back(std::make_unique<FireBolt>(FireBolt(p.pos,{cos(angleToCursor)*200,sin(angleToCursor)*200},12,p.GetAttack(),true,{240,120,60})));
return true;
}

@ -196,6 +196,7 @@
<ClInclude Include="State.h" />
<ClInclude Include="TMXParser.h" />
<ClInclude Include="TSXParser.h" />
<ClInclude Include="utils.h" />
<ClInclude Include="Version.h" />
</ItemGroup>
<ItemGroup>
@ -206,12 +207,14 @@
<ClCompile Include="DamageNumber.cpp" />
<ClCompile Include="Effect.cpp" />
<ClCompile Include="EnergyBolt.cpp" />
<ClCompile Include="FireBolt.cpp" />
<ClCompile Include="Map.cpp" />
<ClCompile Include="Pathfinding.cpp" />
<ClCompile Include="pixelGameEngine.cpp" />
<ClCompile Include="Player.cpp" />
<ClCompile Include="Monster.cpp" />
<ClCompile Include="MonsterData.cpp" />
<ClCompile Include="utils.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />

@ -96,6 +96,9 @@
<ClInclude Include="Pathfinding.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="utils.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Player.cpp">
@ -137,6 +140,12 @@
<ClCompile Include="Pathfinding.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="FireBolt.cpp">
<Filter>Source Files\Bullet Types</Filter>
</ClCompile>
<ClCompile Include="utils.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="cpp.hint" />

@ -25,9 +25,9 @@ bool Effect::Update(float fElapsedTime){
void Effect::Draw(){
if(fadeout==0){
game->view.DrawPartialDecal(pos-GetFrame().GetSourceRect().size/2,GetFrame().GetSourceImage()->Decal(),GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,{size,size},col);
game->view.DrawPartialDecal(pos-GetFrame().GetSourceRect().size*size/2,GetFrame().GetSourceImage()->Decal(),GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,{size,size},col);
} else {
game->view.DrawPartialDecal(pos-GetFrame().GetSourceRect().size/2,GetFrame().GetSourceImage()->Decal(),GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,{size,size},{col.r,col.g,col.b,uint8_t(fadeout/original_fadeoutTime*255)});
game->view.DrawPartialDecal(pos-GetFrame().GetSourceRect().size*size/2,GetFrame().GetSourceImage()->Decal(),GetFrame().GetSourceRect().pos,GetFrame().GetSourceRect().size,{size,size},{col.r,col.g,col.b,uint8_t(fadeout/original_fadeoutTime*255)});
}
}

@ -2,6 +2,7 @@
#include "Effect.h"
#include "Crawler.h"
#include "DEFINES.h"
#include "utils.h"
INCLUDE_game
@ -10,9 +11,9 @@ EnergyBolt::EnergyBolt(vf2d pos,vf2d vel,float radius,int damage,bool friendly,P
void EnergyBolt::Update(float fElapsedTime){
lastParticleSpawn=std::max(0.f,lastParticleSpawn-fElapsedTime);
if(lastParticleSpawn==0&&animation.GetFrame(internal_animState).GetSourceImage()==&game->GFX_EnergyBolt){
if(lastParticleSpawn==0){
lastParticleSpawn=0.03;
game->AddEffect(Effect(pos,float(rand()%500)/500,AnimationState::ENERGY_PARTICLE,float(rand()%1000)/500,0.5,{float(rand()%60)-30,float(rand()%60)-30}));
game->AddEffect(Effect(pos,util::random(1),AnimationState::ENERGY_PARTICLE,util::random(2),0.5,{util::random(60)-30,util::random(60)-30}));
}
}

@ -0,0 +1,43 @@
#include "BulletTypes.h"
#include "Effect.h"
#include "Crawler.h"
#include "DEFINES.h"
#include "utils.h"
INCLUDE_game
INCLUDE_MONSTER_LIST
FireBolt::FireBolt(vf2d pos,vf2d vel,float radius,int damage,bool friendly,Pixel col)
:Bullet(pos,vel,radius,damage,AnimationState::ENERGY_BOLT,false,INFINITE,true,friendly,col){}
void FireBolt::Update(float fElapsedTime){
lastParticleSpawn=std::max(0.f,lastParticleSpawn-fElapsedTime);
if(lastParticleSpawn==0){
lastParticleSpawn=0.03;
game->AddEffect(Effect(pos,util::random(1),AnimationState::ENERGY_PARTICLE,util::random(2),0.3,{util::random(120)-60,-util::random(60)},{255,uint8_t(util::random(250)),0}));
}
}
bool FireBolt::PlayerHit(Player& player)
{
deactivated=true;
fadeOutTime=0.2f;
game->AddEffect(Effect(player.GetPos(),0,AnimationState::SPLASH_EFFECT,5,0.25,{},{240,120,60}));
return false;
}
bool FireBolt::MonsterHit(Monster& monster)
{
deactivated=true;
fadeOutTime=0.2f;
for(int i=0;i<72;i++){
game->AddEffect(Effect(monster.GetPos(),util::random(0.5),AnimationState::DOT_PARTICLE,util::random(2),util::random(0.4),{util::random(300)-150,util::random(300)-150},{255,uint8_t(util::random(190)+60),60}));
}
for(Monster&m:MONSTER_LIST){
if(geom2d::line(monster.GetPos(),m.GetPos()).length()<=2.5*24){
m.Hurt(3*damage);
}
}
game->AddEffect(Effect(monster.GetPos(),0,AnimationState::SPLASH_EFFECT,5,0.25,{},{240,120,60}));
return false;
}

@ -164,8 +164,7 @@ bool Monster::Update(float fElapsedTime){
targetAcquireTimer=1;
if(line.length()<24*6){
target=line.upoint(-1.2);
geom2d::line moveTowardsLine=geom2d::line(pos,target);
if(canMove&&abs(moveTowardsLine.vector().norm().x)>=0.5){
if(canMove){
state=MOVE_AWAY;
} else {
state=NORMAL;
@ -183,7 +182,8 @@ bool Monster::Update(float fElapsedTime){
switch(state){
case MOVE_TOWARDS:{
if(moveTowardsLine.length()>1){
canMove=SetPosition(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult());
vf2d newPos=pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult();
canMove=SetX(newPos.x)&&SetY(newPos.y);
}
if(line.length()<=24*7){
state=NORMAL;
@ -197,7 +197,8 @@ bool Monster::Update(float fElapsedTime){
}break;
case MOVE_AWAY:{
if(moveTowardsLine.length()>1){
canMove=SetPosition(pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult());
vf2d newPos=pos+moveTowardsLine.vector().norm()*100*fElapsedTime*GetMoveSpdMult();
canMove=SetX(newPos.x)&&SetY(newPos.y);
}
if(line.length()>=24*6){
state=NORMAL;

@ -2,7 +2,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 2
#define VERSION_PATCH 0
#define VERSION_BUILD 451
#define VERSION_BUILD 472
#define stringify(a) stringify_(a)
#define stringify_(a) #a

@ -505,6 +505,31 @@
<property name="Type" type="int" propertytype="MonsterName" value="2"/>
</properties>
</property>
<property name="Monster3" type="class" propertytype="Monster">
<properties>
<property name="Type" type="int" propertytype="MonsterName" value="1"/>
</properties>
</property>
<property name="Monster4" type="class" propertytype="Monster">
<properties>
<property name="Type" type="int" propertytype="MonsterName" value="1"/>
</properties>
</property>
<property name="Monster5" type="class" propertytype="Monster">
<properties>
<property name="Type" type="int" propertytype="MonsterName" value="3"/>
</properties>
</property>
<property name="Monster6" type="class" propertytype="Monster">
<properties>
<property name="Type" type="int" propertytype="MonsterName" value="1"/>
</properties>
</property>
<property name="Monster7" type="class" propertytype="Monster">
<properties>
<property name="Type" type="int" propertytype="MonsterName" value="1"/>
</properties>
</property>
</properties>
<ellipse/>
</object>

@ -0,0 +1,5 @@
#include "utils.h"
float util::random(float range){
return float(rand())/RAND_MAX*range;
}

@ -0,0 +1,6 @@
#pragma once
#include <stdlib.h>
namespace util{
//Returns 0-range (as a float).
float random(float range);
}
Loading…
Cancel
Save