|
|
|
@ -128,6 +128,9 @@ void Crawler::InitializeAnimations(){ |
|
|
|
|
if(state==4){//These are death animations.
|
|
|
|
|
anim=Animate2D::FrameSequence(0.1f,Animate2D::Style::OneShot); |
|
|
|
|
} |
|
|
|
|
if(state==2){//These are death animations.
|
|
|
|
|
anim=Animate2D::FrameSequence(0.06f); |
|
|
|
|
} |
|
|
|
|
for (int frame=0;frame<10;frame++){ |
|
|
|
|
anim.AddFrame({&GFX_Slime_Sheet,{vi2d{frame,state+5*slime}*24,{24,24}}}); |
|
|
|
|
} |
|
|
|
@ -173,53 +176,54 @@ void Crawler::HandleUserInput(float fElapsedTime){ |
|
|
|
|
if(GetKey(SPACE).bPressed&&player.GetState()==State::NORMAL&&player.GetGroundSlamCooldown()==0){ |
|
|
|
|
player.Spin(Player::GROUND_SLAM_SPIN_TIME,14*PI); |
|
|
|
|
} |
|
|
|
|
if(RightHeld()){ |
|
|
|
|
if(player.GetPos().x+12+fElapsedTime*100*player.GetMoveSpdMult()<WORLD_SIZE.x*24){ |
|
|
|
|
player.SetX(player.GetX()+fElapsedTime*100*player.GetMoveSpdMult()); |
|
|
|
|
} else { |
|
|
|
|
player.SetX(WORLD_SIZE.x*24-12); |
|
|
|
|
} |
|
|
|
|
player.SetFacingDirection(RIGHT); |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_E); |
|
|
|
|
setIdleAnimation=false; |
|
|
|
|
} |
|
|
|
|
if(LeftHeld()){ |
|
|
|
|
if(player.GetPos().x-12+fElapsedTime*100*player.GetMoveSpdMult()>0){ |
|
|
|
|
player.SetX(player.GetX()-fElapsedTime*100*player.GetMoveSpdMult()); |
|
|
|
|
} else { |
|
|
|
|
player.SetX(12); |
|
|
|
|
} |
|
|
|
|
if(setIdleAnimation){ |
|
|
|
|
player.SetFacingDirection(LEFT); |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_W); |
|
|
|
|
} |
|
|
|
|
setIdleAnimation=false; |
|
|
|
|
} |
|
|
|
|
if(UpHeld()){ |
|
|
|
|
if(player.GetPos().y-12+fElapsedTime*100*player.GetMoveSpdMult()>0){ |
|
|
|
|
player.SetY(player.GetY()-fElapsedTime*100*player.GetMoveSpdMult()); |
|
|
|
|
} else { |
|
|
|
|
player.SetY(12); |
|
|
|
|
if(player.GetVelocity()==vf2d{0,0}){ |
|
|
|
|
if(RightHeld()){ |
|
|
|
|
if(player.GetPos().x+12*player.GetSizeMult()+fElapsedTime*100*player.GetMoveSpdMult()<WORLD_SIZE.x*24){ |
|
|
|
|
player.SetX(player.GetX()+fElapsedTime*100*player.GetMoveSpdMult()); |
|
|
|
|
} else { |
|
|
|
|
player.SetX(WORLD_SIZE.x*24-12); |
|
|
|
|
} |
|
|
|
|
player.SetFacingDirection(RIGHT); |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_E); |
|
|
|
|
setIdleAnimation=false; |
|
|
|
|
} |
|
|
|
|
if(setIdleAnimation){ |
|
|
|
|
player.SetFacingDirection(UP); |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_N); |
|
|
|
|
if(LeftHeld()){ |
|
|
|
|
if(player.GetPos().x-12*player.GetSizeMult()+fElapsedTime*100*player.GetMoveSpdMult()>0){ |
|
|
|
|
player.SetX(player.GetX()-fElapsedTime*100*player.GetMoveSpdMult()); |
|
|
|
|
} else { |
|
|
|
|
player.SetX(12); |
|
|
|
|
} |
|
|
|
|
if(setIdleAnimation){ |
|
|
|
|
player.SetFacingDirection(LEFT); |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_W); |
|
|
|
|
} |
|
|
|
|
setIdleAnimation=false; |
|
|
|
|
} |
|
|
|
|
setIdleAnimation=false; |
|
|
|
|
} |
|
|
|
|
if(DownHeld()){ |
|
|
|
|
if(player.GetPos().y+12+fElapsedTime*100*player.GetMoveSpdMult()<WORLD_SIZE.y*24){ |
|
|
|
|
player.SetY(player.GetY()+fElapsedTime*100*player.GetMoveSpdMult()); |
|
|
|
|
} else { |
|
|
|
|
player.SetY(WORLD_SIZE.y*24-12); |
|
|
|
|
if(UpHeld()){ |
|
|
|
|
if(player.GetPos().y-12*player.GetSizeMult()+fElapsedTime*100*player.GetMoveSpdMult()>0){ |
|
|
|
|
player.SetY(player.GetY()-fElapsedTime*100*player.GetMoveSpdMult()); |
|
|
|
|
} else { |
|
|
|
|
player.SetY(12); |
|
|
|
|
} |
|
|
|
|
if(setIdleAnimation){ |
|
|
|
|
player.SetFacingDirection(UP); |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_N); |
|
|
|
|
} |
|
|
|
|
setIdleAnimation=false; |
|
|
|
|
} |
|
|
|
|
if(setIdleAnimation){ |
|
|
|
|
player.SetFacingDirection(DOWN); |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_S); |
|
|
|
|
if(DownHeld()){ |
|
|
|
|
if(player.GetPos().y+12*player.GetSizeMult()+fElapsedTime*100*player.GetMoveSpdMult()<WORLD_SIZE.y*24){ |
|
|
|
|
player.SetY(player.GetY()+fElapsedTime*100*player.GetMoveSpdMult()); |
|
|
|
|
} else { |
|
|
|
|
player.SetY(WORLD_SIZE.y*24-12); |
|
|
|
|
} |
|
|
|
|
if(setIdleAnimation){ |
|
|
|
|
player.SetFacingDirection(DOWN); |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_S); |
|
|
|
|
} |
|
|
|
|
setIdleAnimation=false; |
|
|
|
|
} |
|
|
|
|
setIdleAnimation=false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(UpReleased()){ |
|
|
|
|
player.SetLastReleasedMovementKey(UP); |
|
|
|
|
if(RightHeld()){ |
|
|
|
@ -347,11 +351,11 @@ void Crawler::RenderWorld(float fElapsedTime){ |
|
|
|
|
e.Draw(); |
|
|
|
|
} |
|
|
|
|
for(Monster&m:monstersBefore){ |
|
|
|
|
view.DrawPartialDecal(m.GetPos()-vf2d{12,12}*m.GetSizeMult(),m.GetFrame().GetSourceImage()->Decal(),m.GetFrame().GetSourceRect().pos,m.GetFrame().GetSourceRect().size,vf2d(m.GetSizeMult(),m.GetSizeMult())); |
|
|
|
|
m.Draw(); |
|
|
|
|
} |
|
|
|
|
view.DrawPartialRotatedDecal(player.GetPos()+vf2d{0,-player.GetZ()},player.GetFrame().GetSourceImage()->Decal(),player.GetSpinAngle(),{12,12},player.GetFrame().GetSourceRect().pos,player.GetFrame().GetSourceRect().size,vf2d(player.GetSizeMult(),player.GetSizeMult())); |
|
|
|
|
for(Monster&m:monstersAfter){ |
|
|
|
|
view.DrawPartialDecal(m.GetPos()-vf2d{12,12}*m.GetSizeMult(),m.GetFrame().GetSourceImage()->Decal(),m.GetFrame().GetSourceRect().pos,m.GetFrame().GetSourceRect().size,vf2d(m.GetSizeMult(),m.GetSizeMult())); |
|
|
|
|
m.Draw(); |
|
|
|
|
} |
|
|
|
|
for(Effect&e:foregroundEffects){ |
|
|
|
|
e.Draw(); |
|
|
|
@ -374,6 +378,10 @@ void Crawler::RenderWorld(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Player&Crawler::GetPlayer(){ |
|
|
|
|
return player; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Crawler::RenderHud(){ |
|
|
|
|
if(player.GetGroundSlamCooldown()>0){ |
|
|
|
|
FillRectDecal({10,ScreenHeight()-22.f},{64,6},BLACK); |
|
|
|
|