|
|
|
@ -88,6 +88,7 @@ State Player::GetState(){ |
|
|
|
|
|
|
|
|
|
void Player::Update(float fElapsedTime){ |
|
|
|
|
attack_cooldown_timer=std::max(0.f,attack_cooldown_timer-fElapsedTime); |
|
|
|
|
iframe_time=std::max(0.f,iframe_time-fElapsedTime); |
|
|
|
|
switch(state){ |
|
|
|
|
case SPIN:{ |
|
|
|
|
switch(facingDirection){ |
|
|
|
@ -132,7 +133,7 @@ void Player::Update(float fElapsedTime){ |
|
|
|
|
animation.UpdateState(internal_animState,fElapsedTime); |
|
|
|
|
groundSlamCooldown=std::max(0.f,groundSlamCooldown-fElapsedTime); |
|
|
|
|
for(Monster&m:MONSTER_LIST){ |
|
|
|
|
if(geom2d::overlaps(geom2d::circle(pos,12*size/2),geom2d::circle(m.GetPos(),12*m.GetSizeMult()/2))){ |
|
|
|
|
if(iframe_time==0&&geom2d::overlaps(geom2d::circle(pos,12*size/2),geom2d::circle(m.GetPos(),12*m.GetSizeMult()/2))){ |
|
|
|
|
if(m.IsAlive()){ |
|
|
|
|
m.Collision(*this); |
|
|
|
|
} |
|
|
|
@ -212,8 +213,12 @@ vf2d Player::GetVelocity(){ |
|
|
|
|
return vel; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Player::Hurt(int damage){ |
|
|
|
|
if(hp<=0) return; |
|
|
|
|
bool Player::HasIframes(){ |
|
|
|
|
return iframe_time>0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool Player::Hurt(int damage){ |
|
|
|
|
if(hp<=0||iframe_time!=0) return false; |
|
|
|
|
hp=std::max(0,hp-damage); |
|
|
|
|
DAMAGENUMBER_LIST.push_back(DamageNumber(pos,damage)); |
|
|
|
|
} |
|
|
|
|