From 306473ff9a5c1d2d2bf965d78d6d0bb9fc64f965 Mon Sep 17 00:00:00 2001 From: Nic0Nic0Nii Date: Mon, 12 Jun 2023 20:22:40 +0000 Subject: [PATCH] Shadow added when player is in air Co-authored-by: sigonasr2 --- Crawler/Crawler.cpp | 13 +++++++++++-- Crawler/Player.cpp | 8 ++++++++ Crawler/Player.h | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Crawler/Crawler.cpp b/Crawler/Crawler.cpp index 81b418ff..8978e726 100644 --- a/Crawler/Crawler.cpp +++ b/Crawler/Crawler.cpp @@ -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()=pl.GetPos().y;}); std::sort(monstersBefore.begin(),monstersBefore.end(),[](Monster&m1,Monster&m2){return m1.GetPos().y0){ + 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())); } diff --git a/Crawler/Player.cpp b/Crawler/Player.cpp index f99d6ee2..de772532 100644 --- a/Crawler/Player.cpp +++ b/Crawler/Player.cpp @@ -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; } diff --git a/Crawler/Player.h b/Crawler/Player.h index 8a6fe275..6ebbe09f 100644 --- a/Crawler/Player.h +++ b/Crawler/Player.h @@ -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();