Shadow added when player is in air

Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
pull/28/head
Nic0Nic0Nii 1 year ago
parent 7caef11d94
commit 306473ff9a
  1. 13
      Crawler/Crawler.cpp
  2. 8
      Crawler/Player.cpp
  3. 2
      Crawler/Player.h

@ -115,6 +115,12 @@ void Crawler::InitializeAnimations(){
void Crawler::HandleUserInput(float fElapsedTime){
bool setIdleAnimation=true;
if(GetKey(PGUP).bHeld){
player.SetZ(player.GetZ()+5*fElapsedTime);
}
if(GetKey(PGDN).bHeld){
player.SetZ(std::max(0.f,player.GetZ()-5*fElapsedTime));
}
if(GetKey(RIGHT).bHeld){
if(player.GetPos().x+12+fElapsedTime*100*player.GetMoveSpdMult()<WORLD_SIZE.x*24){
player.SetX(player.GetX()+fElapsedTime*100*player.GetMoveSpdMult());
@ -249,11 +255,14 @@ void Crawler::RenderWorld(float fElapsedTime){
std::copy_if(MONSTER_LIST.begin(),MONSTER_LIST.end(),std::back_inserter(monstersAfter),[&pl](Monster&m){return m.GetPos().y>=pl.GetPos().y;});
std::sort(monstersBefore.begin(),monstersBefore.end(),[](Monster&m1,Monster&m2){return m1.GetPos().y<m2.GetPos().y;});
std::sort(monstersAfter.begin(),monstersAfter.end(),[](Monster&m1,Monster&m2){return m1.GetPos().y<m2.GetPos().y;});
view.DrawDecal(player.GetPos()+vf2d{-12,12-4},GFX_Circle.Decal(),{24/3,1});
if(player.GetZ()>0){
vf2d shadowScale=vf2d{8/3.f,1}/std::max(1.f,player.GetZ()/4);
view.DrawDecal(player.GetPos()-vf2d{3,3}*shadowScale/2+vf2d{0,6},GFX_Circle.Decal(),shadowScale);
}
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()));
}
view.DrawPartialDecal(player.GetPos()-vf2d{12,12}*player.GetSizeMult(),player.GetFrame().GetSourceImage()->Decal(),player.GetFrame().GetSourceRect().pos,player.GetFrame().GetSourceRect().size,vf2d(player.GetSizeMult(),player.GetSizeMult()));
view.DrawPartialDecal(player.GetPos()-vf2d{12,12}*player.GetSizeMult()+vf2d{0,-player.GetZ()},player.GetFrame().GetSourceImage()->Decal(),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()));
}

@ -26,6 +26,10 @@ void Player::SetY(float y){
pos.y=y;
}
void Player::SetZ(float z){
this->z=z;
}
void Player::SetPos(vf2d pos){
this->pos=pos;
}
@ -42,6 +46,10 @@ float Player::GetY(){
return pos.y;
}
float Player::GetZ(){
return z;
}
int Player::GetHealth(){
return hp;
}

@ -22,10 +22,12 @@ public:
Player(vf2d pos);
void SetX(float x);
void SetY(float y);
void SetZ(float z);
void SetPos(vf2d pos);
vf2d&GetPos();
float GetX();
float GetY();
float GetZ();
int GetHealth();
int GetMaxHealth();
int GetAttack();

Loading…
Cancel
Save