Hamster landing speed controls.

main
sigonasr2 3 months ago
parent fa25cfa54c
commit a16dc51d23
  1. 6
      src/Hamster.cpp
  2. 1
      src/Hamster.h
  3. 4
      src/HamsterGame.cpp
  4. 16
      src/HamsterJet.cpp
  5. 1
      src/HamsterJet.h

@ -215,6 +215,10 @@ void Hamster::DrawHamsters(TransformedView&tv){
}
}
void Hamster::DrawOverlay(){
if(GetPlayer().hamsterJet.has_value())GetPlayer().hamsterJet.value().DrawOverlay();
}
const Animate2D::Frame&Hamster::GetCurrentAnimation()const{
return animations.GetFrame(internalAnimState);
}
@ -307,7 +311,7 @@ void Hamster::HandleCollision(){
}
}
for(Powerup&powerup:Powerup::GetPowerups()){
if(!HasPowerup(powerup.GetType())&&geom2d::overlaps(geom2d::circle<float>(GetPos(),collisionRadius),geom2d::circle<float>(powerup.GetPos(),20.f))){
if(z<=0.1f&&!HasPowerup(powerup.GetType())&&geom2d::overlaps(geom2d::circle<float>(GetPos(),collisionRadius),geom2d::circle<float>(powerup.GetPos(),20.f))){
ObtainPowerup(powerup.GetType());
powerup.OnPowerupObtain();
}

@ -109,6 +109,7 @@ public:
static void UpdateHamsters(const float fElapsedTime);
static void LoadHamsters(const vf2d startingLoc);
static void DrawHamsters(TransformedView&tv);
static void DrawOverlay();
const Animate2D::Frame&GetCurrentAnimation()const;
const vf2d&GetPos()const;
const float&GetZ()const;

@ -48,6 +48,8 @@ void HamsterGame::LoadGraphics(){
_LoadImage("dot.png");
_LoadImage("clouds.png");
_LoadImage("aimingTarget.png");
_LoadImage("fallometer.png");
_LoadImage("fallometer_outline.png");
UpdateMatrixTexture();
}
@ -158,7 +160,7 @@ void HamsterGame::DrawGame(){
tv.DrawPartialDecal({-3200,-3200},currentMap.value().GetData().GetMapData().MapSize*16+vf2d{6400,6400},GetGFX("clouds.png").Decal(),cloudOffset*2,currentMap.value().GetData().GetMapData().MapSize*16/2.f,{255,255,255,72});
SetZ(0.f);
border.Draw();
Hamster::DrawOverlay();
#pragma region Powerup Display
for(int y:std::ranges::iota_view(0,4)){
for(int x:std::ranges::iota_view(0,2)){

@ -175,6 +175,12 @@ void HamsterJet::HandleJetControls(){
hamster.vel=vf2d{std::min(hamster.GetMaxSpeed(),hamster.vel.polar().x),hamster.vel.polar().y}.cart();
hamster.frictionEnabled=false;
}
if(HamsterGame::Game().GetKey(UP).bHeld){
fallSpd=std::min(5.f,fallSpd+5.f*HamsterGame::Game().GetElapsedTime());
}
if(HamsterGame::Game().GetKey(DOWN).bHeld){
fallSpd=std::max(1.f,fallSpd-5.f*HamsterGame::Game().GetElapsedTime());
}
if(HamsterGame::Game().GetKey(SPACE).bPressed){
if(lastTappedSpace<=0.6f){
state=LANDING;
@ -185,4 +191,14 @@ void HamsterJet::HandleJetControls(){
const HamsterJet::State HamsterJet::GetState()const{
return state;
}
void HamsterJet::DrawOverlay()const{
if(state==LANDING){
HamsterGame::Game().DrawDecal(HamsterGame::SCREEN_FRAME.pos,HamsterGame::GetGFX("fallometer_outline.png").Decal());
float meterStartY{68.f};
float meterEndY{223.f};
float meterHeight{meterEndY-meterStartY};
HamsterGame::Game().DrawPartialDecal(HamsterGame::SCREEN_FRAME.pos+vf2d{0,222}-vf2d{0,(fallSpd/5.f)*meterHeight},HamsterGame::GetGFX("fallometer.png").Decal(),vf2d{0,223}-vf2d{0,(fallSpd/5.f)*meterHeight},vf2d{float(HamsterGame::GetGFX("fallometer.png").Sprite()->width),(fallSpd/5.f)*meterHeight});
}
}

@ -81,6 +81,7 @@ public:
HamsterJet(Hamster&hamster);
void Update(const float fElapsedTime);
void Draw();
void DrawOverlay()const;
void HandleJetControls();
const State GetState()const;
};
Loading…
Cancel
Save