Added ghost fading images for retreat ability and facing direction implemented.
This commit is contained in:
parent
8685e3b5ef
commit
a8f83dfec8
@ -570,6 +570,11 @@ void Crawler::RenderWorld(float fElapsedTime){
|
|||||||
vf2d playerScale=vf2d(player->GetSizeMult(),player->GetSizeMult());
|
vf2d playerScale=vf2d(player->GetSizeMult(),player->GetSizeMult());
|
||||||
vf2d playerPosition=player->GetPos();
|
vf2d playerPosition=player->GetPos();
|
||||||
auto RenderPlayer=[&](){
|
auto RenderPlayer=[&](){
|
||||||
|
int count=0;
|
||||||
|
for(vf2d&pos:player->ghostPositions){
|
||||||
|
view.DrawPartialRotatedDecal(pos,player->GetFrame().GetSourceImage()->Decal(),player->GetSpinAngle(),{12,12},player->GetFrame().GetSourceRect().pos,player->GetFrame().GetSourceRect().size,playerScale,{0,0,0,uint8_t(float(count)/player->RETREAT_GHOST_FRAMES*255)});
|
||||||
|
count++;
|
||||||
|
}
|
||||||
if(player->teleportAnimationTimer>0){
|
if(player->teleportAnimationTimer>0){
|
||||||
playerScale.x=120*abs(pow(player->teleportAnimationTimer-0.175,3));
|
playerScale.x=120*abs(pow(player->teleportAnimationTimer-0.175,3));
|
||||||
playerPosition=player->teleportStartPosition.lerp(player->teleportTarget,(0.35-player->teleportAnimationTimer)/0.35);
|
playerPosition=player->teleportStartPosition.lerp(player->teleportTarget,(0.35-player->teleportAnimationTimer)/0.35);
|
||||||
@ -577,7 +582,7 @@ void Crawler::RenderWorld(float fElapsedTime){
|
|||||||
} else {
|
} else {
|
||||||
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);
|
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);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
//define end
|
//define end
|
||||||
if(!player->upperLevel){
|
if(!player->upperLevel){
|
||||||
RenderPlayer();
|
RenderPlayer();
|
||||||
|
@ -542,3 +542,18 @@ void Player::PrepareCast(Ability&ability){
|
|||||||
void Player::SetVelocity(vf2d vel){
|
void Player::SetVelocity(vf2d vel){
|
||||||
this->vel=vel;
|
this->vel=vel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::SetAnimationBasedOnTargetingDirection(float targetDirection){
|
||||||
|
if(targetDirection<=PI/4&&targetDirection>-PI/4){
|
||||||
|
UpdateAnimation(AnimationState::RANGER_SHOOT_E);
|
||||||
|
} else
|
||||||
|
if(targetDirection>=3*PI/4||targetDirection<-3*PI/4){
|
||||||
|
UpdateAnimation(AnimationState::RANGER_SHOOT_W);
|
||||||
|
} else
|
||||||
|
if(targetDirection<=3*PI/4&&targetDirection>PI/4){
|
||||||
|
UpdateAnimation(AnimationState::RANGER_SHOOT_S);
|
||||||
|
} else
|
||||||
|
if(targetDirection>=-3*PI/4&&targetDirection<-PI/4){
|
||||||
|
UpdateAnimation(AnimationState::RANGER_SHOOT_N);
|
||||||
|
}
|
||||||
|
}
|
@ -152,6 +152,7 @@ public:
|
|||||||
virtual AnimationState&GetIdleWAnimation()=0;
|
virtual AnimationState&GetIdleWAnimation()=0;
|
||||||
|
|
||||||
CastInfo&GetCastInfo();
|
CastInfo&GetCastInfo();
|
||||||
|
void SetAnimationBasedOnTargetingDirection(float targetDirection);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Warrior:Player{
|
struct Warrior:Player{
|
||||||
|
@ -40,6 +40,7 @@ void Ranger::OnUpdate(float fElapsedTime){
|
|||||||
if(retreatTimer<=0){
|
if(retreatTimer<=0){
|
||||||
SetVelocity({});
|
SetVelocity({});
|
||||||
SetZ(0);
|
SetZ(0);
|
||||||
|
SetState(State::NORMAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(ghostRemoveTimer>0){
|
if(ghostRemoveTimer>0){
|
||||||
@ -53,27 +54,23 @@ void Ranger::OnUpdate(float fElapsedTime){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(ghostFrameTimer>0){
|
||||||
|
ghostFrameTimer-=fElapsedTime;
|
||||||
|
if(ghostFrameTimer<=0&&GetState()==State::RETREAT){
|
||||||
|
ghostPositions.push_back(GetPos()+vf2d{0,-GetZ()});
|
||||||
|
ghostFrameTimer=RETREAT_GHOST_FRAME_DELAY;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Ranger::AutoAttack(){
|
bool Ranger::AutoAttack(){
|
||||||
attack_cooldown_timer=ARROW_ATTACK_COOLDOWN;
|
|
||||||
geom2d::line pointTowardsCursor(GetPos(),game->GetWorldMousePos());
|
geom2d::line pointTowardsCursor(GetPos(),game->GetWorldMousePos());
|
||||||
vf2d extendedLine=pointTowardsCursor.upoint(1.1);
|
vf2d extendedLine=pointTowardsCursor.upoint(1.1);
|
||||||
float angleToCursor=atan2(extendedLine.y-GetPos().y,extendedLine.x-GetPos().x);
|
float angleToCursor=atan2(extendedLine.y-GetPos().y,extendedLine.x-GetPos().x);
|
||||||
|
attack_cooldown_timer=ARROW_ATTACK_COOLDOWN;
|
||||||
BULLET_LIST.push_back(std::make_unique<Arrow>(Arrow(GetPos(),extendedLine,vf2d{cos(angleToCursor)*250,float(sin(angleToCursor)*250-PI/8*250)}+movementVelocity,12,GetAttack(),OnUpperLevel(),true)));
|
BULLET_LIST.push_back(std::make_unique<Arrow>(Arrow(GetPos(),extendedLine,vf2d{cos(angleToCursor)*250,float(sin(angleToCursor)*250-PI/8*250)}+movementVelocity,12,GetAttack(),OnUpperLevel(),true)));
|
||||||
SetState(State::SHOOT_ARROW);
|
SetState(State::SHOOT_ARROW);
|
||||||
if(angleToCursor<=PI/4&&angleToCursor>-PI/4){
|
SetAnimationBasedOnTargetingDirection(angleToCursor);
|
||||||
UpdateAnimation(AnimationState::RANGER_SHOOT_E);
|
|
||||||
} else
|
|
||||||
if(angleToCursor>=3*PI/4||angleToCursor<-3*PI/4){
|
|
||||||
UpdateAnimation(AnimationState::RANGER_SHOOT_W);
|
|
||||||
} else
|
|
||||||
if(angleToCursor<=3*PI/4&&angleToCursor>PI/4){
|
|
||||||
UpdateAnimation(AnimationState::RANGER_SHOOT_S);
|
|
||||||
} else
|
|
||||||
if(angleToCursor>=-3*PI/4&&angleToCursor<-PI/4){
|
|
||||||
UpdateAnimation(AnimationState::RANGER_SHOOT_N);
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,9 +83,12 @@ void Ranger::InitializeClassAbilities(){
|
|||||||
p->SetVelocity(mouseDir.vector().norm()*velocity);
|
p->SetVelocity(mouseDir.vector().norm()*velocity);
|
||||||
p->retreatTimer=p->RETREAT_TIME;
|
p->retreatTimer=p->RETREAT_TIME;
|
||||||
p->iframe_time=p->RETREAT_TIME;
|
p->iframe_time=p->RETREAT_TIME;
|
||||||
p->ghostPositions.push_back(p->GetPos());
|
p->ghostPositions.push_back(p->GetPos()+vf2d{0,-p->GetZ()});
|
||||||
p->ghostFrameTimer=p->RETREAT_GHOST_FRAME_DELAY;
|
p->ghostFrameTimer=p->RETREAT_GHOST_FRAME_DELAY;
|
||||||
p->ghostRemoveTimer=p->RETREAT_GHOST_FRAMES*p->RETREAT_GHOST_FRAME_DELAY;
|
p->ghostRemoveTimer=p->RETREAT_GHOST_FRAMES*p->RETREAT_GHOST_FRAME_DELAY;
|
||||||
|
float angleToCursor=atan2(game->GetWorldMousePos().y-p->GetPos().y,game->GetWorldMousePos().x-p->GetPos().x);
|
||||||
|
p->SetAnimationBasedOnTargetingDirection(angleToCursor);
|
||||||
|
p->SetState(State::RETREAT);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 2
|
#define VERSION_MINOR 2
|
||||||
#define VERSION_PATCH 0
|
#define VERSION_PATCH 0
|
||||||
#define VERSION_BUILD 810
|
#define VERSION_BUILD 828
|
||||||
|
|
||||||
#define stringify(a) stringify_(a)
|
#define stringify(a) stringify_(a)
|
||||||
#define stringify_(a) #a
|
#define stringify_(a) #a
|
||||||
|
3
Crawler/test
Normal file
3
Crawler/test
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
test 1
|
||||||
|
test 2
|
||||||
|
test 3
|
Loading…
x
Reference in New Issue
Block a user