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.
20 lines
446 B
20 lines
446 B
#include "Bullet.h"
|
|
|
|
Bullet::Bullet(olc::vi2d pos)
|
|
:pos(pos){}
|
|
olc::vf2d Bullet::GetPos(){
|
|
return pos;
|
|
}
|
|
void Bullet::Update(float fElapsedTime){
|
|
pos+={0,-72*fElapsedTime};
|
|
}
|
|
bool Bullet::CollidesWith(Enemy&enemy){
|
|
float dist2=pow(enemy.GetPos().x+enemy.GetSprSize().x-pos.x,2)+pow(enemy.GetPos().y+enemy.GetSprSize().y-pos.y,2);
|
|
return dist2<64;
|
|
}
|
|
void Bullet::KillBullet(){
|
|
alive=false;
|
|
}
|
|
bool Bullet::IsAlive(){
|
|
return alive||pos.y<0;
|
|
} |