Add Spinning attack animation
This commit is contained in:
@@ -11,6 +11,8 @@ extern std::vector<MonsterSpawner>SPAWNER_LIST;
|
||||
extern std::vector<DamageNumber>DAMAGENUMBER_LIST;
|
||||
extern Crawler*game;
|
||||
|
||||
const float Player::GROUND_SLAM_SPIN_TIME=0.6f;
|
||||
|
||||
Player::Player(){
|
||||
}
|
||||
|
||||
@@ -74,8 +76,52 @@ float Player::GetAttackRangeMult(){
|
||||
return attack_range;
|
||||
}
|
||||
|
||||
float Player::GetSpinAngle(){
|
||||
return spin_angle;
|
||||
}
|
||||
|
||||
State Player::GetState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
void Player::Update(float fElapsedTime){
|
||||
attack_cooldown_timer=std::max(0.f,attack_cooldown_timer-fElapsedTime);
|
||||
switch(state){
|
||||
case SPIN:{
|
||||
switch(lastReleasedMovementKey){
|
||||
case UP:{
|
||||
if(lastAnimationFlip==0){
|
||||
lastAnimationFlip=0.03;
|
||||
lastReleasedMovementKey=DOWN;
|
||||
animation.ChangeState(internal_animState,AnimationState::WALK_S);
|
||||
}
|
||||
}break;
|
||||
case DOWN:{
|
||||
if(lastAnimationFlip==0){
|
||||
lastAnimationFlip=0.03;
|
||||
lastReleasedMovementKey=UP;
|
||||
animation.ChangeState(internal_animState,AnimationState::WALK_N);
|
||||
}
|
||||
}break;
|
||||
}
|
||||
if(lastReleasedMovementKey==DOWN||lastReleasedMovementKey==RIGHT){
|
||||
spin_angle-=spin_spd*fElapsedTime;
|
||||
} else {
|
||||
spin_angle+=spin_spd*fElapsedTime;
|
||||
}
|
||||
if(spin_attack_timer>0){
|
||||
z=50*sin(3.3*(GROUND_SLAM_SPIN_TIME-spin_attack_timer)/GROUND_SLAM_SPIN_TIME);
|
||||
spin_attack_timer=std::max(0.f,spin_attack_timer-fElapsedTime);
|
||||
} else {
|
||||
state=NORMAL;
|
||||
spin_angle=0;
|
||||
z=0;
|
||||
}
|
||||
}break;
|
||||
default:{
|
||||
//Update animations normally.
|
||||
}
|
||||
}
|
||||
animation.UpdateState(internal_animState,fElapsedTime);
|
||||
if(attack_cooldown_timer==0&&game->GetMouse(0).bHeld){
|
||||
bool attack=false;
|
||||
@@ -123,4 +169,11 @@ void Player::Moved(){
|
||||
spawner.SetTriggered(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::Spin(float duration,float spinSpd){
|
||||
state=State::SPIN;
|
||||
spin_attack_timer=duration;
|
||||
spin_spd=spinSpd;
|
||||
spin_angle=0;
|
||||
}
|
||||
Reference in New Issue
Block a user