diff --git a/Crawler/BulletTypes.h b/Crawler/BulletTypes.h index 40557cdd..eedff62b 100644 --- a/Crawler/BulletTypes.h +++ b/Crawler/BulletTypes.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; }; \ No newline at end of file diff --git a/Crawler/Class.cpp b/Crawler/Class.cpp index c037c586..a705eebb 100644 --- a/Crawler/Class.cpp +++ b/Crawler/Class.cpp @@ -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(p.pos,{cos(angleToCursor)*200,sin(angleToCursor)*200},12,p.GetAttack(),true,{240,120,60}))); return true; } diff --git a/Crawler/Crawler.vcxproj b/Crawler/Crawler.vcxproj index 59c376ab..bb32f7fc 100644 --- a/Crawler/Crawler.vcxproj +++ b/Crawler/Crawler.vcxproj @@ -196,6 +196,7 @@ + @@ -206,12 +207,14 @@ + + diff --git a/Crawler/Crawler.vcxproj.filters b/Crawler/Crawler.vcxproj.filters index c7c21125..f56de6c9 100644 --- a/Crawler/Crawler.vcxproj.filters +++ b/Crawler/Crawler.vcxproj.filters @@ -96,6 +96,9 @@ Header Files + + Header Files + @@ -137,6 +140,12 @@ Source Files + + Source Files\Bullet Types + + + Source Files + diff --git a/Crawler/Effect.cpp b/Crawler/Effect.cpp index 28fa3b26..972b040c 100644 --- a/Crawler/Effect.cpp +++ b/Crawler/Effect.cpp @@ -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)}); } } diff --git a/Crawler/EnergyBolt.cpp b/Crawler/EnergyBolt.cpp index dcad7bac..05bc8dd9 100644 --- a/Crawler/EnergyBolt.cpp +++ b/Crawler/EnergyBolt.cpp @@ -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})); } } diff --git a/Crawler/FireBolt.cpp b/Crawler/FireBolt.cpp new file mode 100644 index 00000000..1445f351 --- /dev/null +++ b/Crawler/FireBolt.cpp @@ -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; +} diff --git a/Crawler/Monster.cpp b/Crawler/Monster.cpp index 6aca2d13..70e4a44c 100644 --- a/Crawler/Monster.cpp +++ b/Crawler/Monster.cpp @@ -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; diff --git a/Crawler/Version.h b/Crawler/Version.h index 3fd90fb2..a2cf9878 100644 --- a/Crawler/Version.h +++ b/Crawler/Version.h @@ -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 diff --git a/Crawler/assets/Campaigns/1_1_test.tmx b/Crawler/assets/Campaigns/1_1_test.tmx index 931dd6dd..9fc96649 100644 --- a/Crawler/assets/Campaigns/1_1_test.tmx +++ b/Crawler/assets/Campaigns/1_1_test.tmx @@ -505,6 +505,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Crawler/utils.cpp b/Crawler/utils.cpp new file mode 100644 index 00000000..a50d1179 --- /dev/null +++ b/Crawler/utils.cpp @@ -0,0 +1,5 @@ +#include "utils.h" + +float util::random(float range){ + return float(rand())/RAND_MAX*range; +} \ No newline at end of file diff --git a/Crawler/utils.h b/Crawler/utils.h new file mode 100644 index 00000000..72b68257 --- /dev/null +++ b/Crawler/utils.h @@ -0,0 +1,6 @@ +#pragma once +#include +namespace util{ + //Returns 0-range (as a float). + float random(float range); +} \ No newline at end of file