parent
79a8dca88a
commit
9ebe5a21a0
@ -0,0 +1,39 @@ |
||||
#include "BulletTypes.h" |
||||
#include "Effect.h" |
||||
#include "Crawler.h" |
||||
#include "DEFINES.h" |
||||
#include "utils.h" |
||||
#include "olcUTIL_Geometry2D.h" |
||||
|
||||
INCLUDE_game |
||||
|
||||
Arrow::Arrow(vf2d pos,vf2d targetPos,vf2d vel,float radius,int damage,bool upperLevel,bool friendly,Pixel col) |
||||
:finalDistance(geom2d::line(pos,targetPos).length()), |
||||
Bullet(pos,vel,radius,damage, |
||||
AnimationState::ARROW,upperLevel,false,INFINITE,true,friendly,col){} |
||||
|
||||
void Arrow::Update(float fElapsedTime){ |
||||
float speed=vel.mag(); |
||||
travelDistance+=speed*fElapsedTime; |
||||
vel.y+=acc*fElapsedTime; |
||||
if(!deactivated&&travelDistance>=finalDistance){ |
||||
deactivated=true; |
||||
fadeOutTime=0.2f; |
||||
} |
||||
} |
||||
|
||||
bool Arrow::PlayerHit(Player*player) |
||||
{ |
||||
deactivated=true; |
||||
fadeOutTime=0.2f; |
||||
game->AddEffect(std::make_unique<Effect>(player->GetPos(),0,AnimationState::SPLASH_EFFECT,upperLevel,player->GetSizeMult(),0.25)); |
||||
return false; |
||||
} |
||||
|
||||
bool Arrow::MonsterHit(Monster& monster) |
||||
{ |
||||
deactivated=true; |
||||
fadeOutTime=0.2f; |
||||
game->AddEffect(std::make_unique<Effect>(monster.GetPos(),0,AnimationState::SPLASH_EFFECT,upperLevel,monster.GetSizeMult(),0.25)); |
||||
return false; |
||||
} |
Loading…
Reference in new issue