Teleport animation implemented.
This commit is contained in:
parent
86f22698cc
commit
0c9469d982
@ -310,7 +310,11 @@ bool Wizard::RightClickAbility(){
|
||||
teleportPoint=p.GetPos()+pointTowardsMouse*dist;
|
||||
}
|
||||
if(dist>0){
|
||||
p.SetPos(teleportPoint);
|
||||
p.SetState(State::TELEPORT);
|
||||
p.teleportAnimationTimer=0.35;
|
||||
p.teleportTarget=teleportPoint;
|
||||
p.teleportStartPosition=p.GetPos();
|
||||
p.iframe_time=0.35;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -731,7 +731,16 @@ void Crawler::RenderWorld(float fElapsedTime){
|
||||
for(Monster&m:monstersBefore){
|
||||
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()),player.GetBuffs(BuffType::ATTACK_UP).size()>0?Pixel{255,uint8_t(255*abs(sin(1.4*player.GetBuffs(BuffType::ATTACK_UP)[0].duration))),uint8_t(255*abs(sin(1.4*player.GetBuffs(BuffType::ATTACK_UP)[0].duration)))}:WHITE);
|
||||
vf2d playerScale=vf2d(player.GetSizeMult(),player.GetSizeMult());
|
||||
vf2d playerPosition=player.GetPos();
|
||||
#define RENDER_PLAYER view.DrawPartialRotatedDecal(playerPosition+vf2d{0,-player.GetZ()},player.GetFrame().GetSourceImage()->Decal(),player.GetSpinAngle(),{12,12},player.GetFrame().GetSourceRect().pos,player.GetFrame().GetSourceRect().size,playerScale,player.GetBuffs(BuffType::ATTACK_UP).size()>0?Pixel{255,uint8_t(255*abs(sin(1.4*player.GetBuffs(BuffType::ATTACK_UP)[0].duration))),uint8_t(255*abs(sin(1.4*player.GetBuffs(BuffType::ATTACK_UP)[0].duration)))}:WHITE);
|
||||
if(player.teleportAnimationTimer>0){
|
||||
playerScale.x=120*abs(pow(player.teleportAnimationTimer-0.175,3));
|
||||
playerPosition=player.teleportStartPosition.lerp(player.teleportTarget,(0.35-player.teleportAnimationTimer)/0.35);
|
||||
RENDER_PLAYER
|
||||
} else {
|
||||
RENDER_PLAYER
|
||||
}
|
||||
if(player.GetState()==State::BLOCK){
|
||||
view.DrawDecal(player.GetPos()-vf2d{12,12},GFX_BLOCK_BUBBLE.Decal());
|
||||
}
|
||||
|
@ -231,6 +231,14 @@ void Player::Update(float fElapsedTime){
|
||||
}
|
||||
animation.UpdateState(internal_animState,fElapsedTime);
|
||||
}break;
|
||||
case TELEPORT:{
|
||||
teleportAnimationTimer=std::max(0.f,teleportAnimationTimer-fElapsedTime);
|
||||
if(teleportAnimationTimer<=0){
|
||||
SetPos(teleportTarget);
|
||||
SetState(NORMAL);
|
||||
}
|
||||
animation.UpdateState(internal_animState,fElapsedTime);
|
||||
}break;
|
||||
default:{
|
||||
//Update animations normally.
|
||||
animation.UpdateState(internal_animState,fElapsedTime);
|
||||
|
@ -38,6 +38,9 @@ struct Player{
|
||||
float swordSwingTimer=0;
|
||||
float iframe_time=0;
|
||||
float manaTickTimer=0;
|
||||
float teleportAnimationTimer=0;
|
||||
vf2d teleportTarget={};
|
||||
vf2d teleportStartPosition={};
|
||||
std::pair<std::string,float> notEnoughManaDisplay={"",0};
|
||||
State state=State::NORMAL;
|
||||
Animate2D::Animation<AnimationState>animation;
|
||||
|
@ -8,4 +8,5 @@ enum State{
|
||||
MOVE_TOWARDS,
|
||||
MOVE_AWAY,
|
||||
BLOCK,
|
||||
TELEPORT,
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user