|
|
|
@ -47,6 +47,10 @@ bool Crawler::OnUserCreate(){ |
|
|
|
|
player.AddAnimation(AnimationState::IDLE_E); |
|
|
|
|
player.AddAnimation(AnimationState::IDLE_S); |
|
|
|
|
player.AddAnimation(AnimationState::IDLE_W); |
|
|
|
|
player.AddAnimation(AnimationState::SWINGSWORD_E); |
|
|
|
|
player.AddAnimation(AnimationState::SWINGSWORD_S); |
|
|
|
|
player.AddAnimation(AnimationState::SWINGSWORD_N); |
|
|
|
|
player.AddAnimation(AnimationState::SWINGSWORD_W); |
|
|
|
|
view=TileTransformedView{GetScreenSize(),{1,1}}; |
|
|
|
|
|
|
|
|
|
player.SetPos({4*24,4*24}); |
|
|
|
@ -148,6 +152,23 @@ void Crawler::InitializeAnimations(){ |
|
|
|
|
Animate2D::FrameSequence pl_idle_n; |
|
|
|
|
pl_idle_n.AddFrame({&GFX_Pl_Sheet,{vi2d{0,1}*24,{24,24}}}); |
|
|
|
|
ANIMATION_DATA[AnimationState::IDLE_N]=pl_idle_n; |
|
|
|
|
Animate2D::FrameSequence pl_swing_s(0.05),pl_swing_n(0.05),pl_swing_e(0.05),pl_swing_w(0.05); |
|
|
|
|
for (int i=0;i<4;i++){ |
|
|
|
|
pl_swing_s.AddFrame({&GFX_Pl_Sheet,{vi2d{4+i,0}*24,{24,24}}}); |
|
|
|
|
} |
|
|
|
|
for (int i=0;i<4;i++){ |
|
|
|
|
pl_swing_n.AddFrame({&GFX_Pl_Sheet,{vi2d{4+i,1}*24,{24,24}}}); |
|
|
|
|
} |
|
|
|
|
for (int i=0;i<4;i++){ |
|
|
|
|
pl_swing_w.AddFrame({&GFX_Pl_Sheet,{vi2d{4+i,2}*24,{24,24}}}); |
|
|
|
|
} |
|
|
|
|
for (int i=0;i<4;i++){ |
|
|
|
|
pl_swing_e.AddFrame({&GFX_Pl_Sheet,{vi2d{4+i,3}*24,{24,24}}}); |
|
|
|
|
} |
|
|
|
|
ANIMATION_DATA[AnimationState::SWINGSWORD_N]=pl_swing_n; |
|
|
|
|
ANIMATION_DATA[AnimationState::SWINGSWORD_E]=pl_swing_e; |
|
|
|
|
ANIMATION_DATA[AnimationState::SWINGSWORD_S]=pl_swing_s; |
|
|
|
|
ANIMATION_DATA[AnimationState::SWINGSWORD_W]=pl_swing_w; |
|
|
|
|
//Load slime animations.
|
|
|
|
|
for(int slime=0;slime<4;slime++){ |
|
|
|
|
for(int state=0;state<5;state++){ |
|
|
|
@ -211,7 +232,9 @@ void Crawler::HandleUserInput(float fElapsedTime){ |
|
|
|
|
player.SetX(WORLD_SIZE.x*24-12); |
|
|
|
|
} |
|
|
|
|
player.SetFacingDirection(RIGHT); |
|
|
|
|
if(player.GetState()==State::NORMAL){ |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_E); |
|
|
|
|
} |
|
|
|
|
setIdleAnimation=false; |
|
|
|
|
} |
|
|
|
|
if(LeftHeld()){ |
|
|
|
@ -222,8 +245,10 @@ void Crawler::HandleUserInput(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
if(setIdleAnimation){ |
|
|
|
|
player.SetFacingDirection(LEFT); |
|
|
|
|
if(player.GetState()==State::NORMAL){ |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_W); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
setIdleAnimation=false; |
|
|
|
|
} |
|
|
|
|
if(UpHeld()){ |
|
|
|
@ -234,8 +259,10 @@ void Crawler::HandleUserInput(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
if(setIdleAnimation){ |
|
|
|
|
player.SetFacingDirection(UP); |
|
|
|
|
if(player.GetState()==State::NORMAL){ |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_N); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
setIdleAnimation=false; |
|
|
|
|
} |
|
|
|
|
if(DownHeld()){ |
|
|
|
@ -246,13 +273,16 @@ void Crawler::HandleUserInput(float fElapsedTime){ |
|
|
|
|
} |
|
|
|
|
if(setIdleAnimation){ |
|
|
|
|
player.SetFacingDirection(DOWN); |
|
|
|
|
if(player.GetState()==State::NORMAL){ |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_S); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
setIdleAnimation=false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(UpReleased()){ |
|
|
|
|
player.SetLastReleasedMovementKey(UP); |
|
|
|
|
if(player.GetState()==State::NORMAL){ |
|
|
|
|
if(RightHeld()){ |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_E); |
|
|
|
|
} else |
|
|
|
@ -263,8 +293,10 @@ void Crawler::HandleUserInput(float fElapsedTime){ |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_W); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(RightReleased()){ |
|
|
|
|
player.SetLastReleasedMovementKey(RIGHT); |
|
|
|
|
if(player.GetState()==State::NORMAL){ |
|
|
|
|
if(UpHeld()){ |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_N); |
|
|
|
|
} else |
|
|
|
@ -275,8 +307,10 @@ void Crawler::HandleUserInput(float fElapsedTime){ |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_W); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(LeftReleased()){ |
|
|
|
|
player.SetLastReleasedMovementKey(LEFT); |
|
|
|
|
if(player.GetState()==State::NORMAL){ |
|
|
|
|
if(RightHeld()){ |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_E); |
|
|
|
|
} else |
|
|
|
@ -287,8 +321,10 @@ void Crawler::HandleUserInput(float fElapsedTime){ |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_N); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if(DownReleased()){ |
|
|
|
|
player.SetLastReleasedMovementKey(DOWN); |
|
|
|
|
if(player.GetState()==State::NORMAL){ |
|
|
|
|
if(RightHeld()){ |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_E); |
|
|
|
|
} else |
|
|
|
@ -299,6 +335,30 @@ void Crawler::HandleUserInput(float fElapsedTime){ |
|
|
|
|
player.UpdateAnimation(AnimationState::WALK_W); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(player.GetState()==State::SWING_SWORD){ |
|
|
|
|
setIdleAnimation=false; |
|
|
|
|
switch(player.GetFacingDirection()){ |
|
|
|
|
case UP:{ |
|
|
|
|
player.UpdateAnimation(AnimationState::SWINGSWORD_N); |
|
|
|
|
}break; |
|
|
|
|
case DOWN:{ |
|
|
|
|
player.UpdateAnimation(AnimationState::SWINGSWORD_S); |
|
|
|
|
}break; |
|
|
|
|
case LEFT:{ |
|
|
|
|
player.UpdateAnimation(AnimationState::SWINGSWORD_W); |
|
|
|
|
}break; |
|
|
|
|
case RIGHT:{ |
|
|
|
|
player.UpdateAnimation(AnimationState::SWINGSWORD_E); |
|
|
|
|
}break; |
|
|
|
|
} |
|
|
|
|
player.SetSwordSwingTimer(player.GetSwordSwingTimer()-fElapsedTime); |
|
|
|
|
if(player.GetSwordSwingTimer()<=0){ |
|
|
|
|
player.SetSwordSwingTimer(0); |
|
|
|
|
player.SetState(State::NORMAL);
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(setIdleAnimation){ |
|
|
|
|
switch(player.GetLastReleasedMovementKey()){ |
|
|
|
|