The open source repository for the action RPG game in development by Sig Productions titled 'Adventures in Lestoria'!
https://forums.lestoria.net
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.1 KiB
39 lines
1.1 KiB
1 year ago
|
#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;
|
||
|
}
|