diff --git a/assets/countdown.png b/assets/countdown.png new file mode 100644 index 0000000..2b83651 Binary files /dev/null and b/assets/countdown.png differ diff --git a/src/AnimationState.h b/src/AnimationState.h index 7cd24d6..9c4df6b 100644 --- a/src/AnimationState.h +++ b/src/AnimationState.h @@ -48,5 +48,6 @@ namespace AnimationState{ CHECKPOINT_CYCLING, CHECKPOINT_COLLECTED, SIDE_VIEW, + COUNTDOWN, }; } \ No newline at end of file diff --git a/src/Hamster.cpp b/src/Hamster.cpp index 1bdfa4a..5fd5471 100644 --- a/src/Hamster.cpp +++ b/src/Hamster.cpp @@ -669,6 +669,7 @@ const float Hamster::GetMaxSpeed()const{ }break; } } + if(!HamsterGame::Game().RaceCountdownCompleted())finalMaxSpd*=0.f; return finalMaxSpd; } const float Hamster::GetFriction()const{ diff --git a/src/HamsterGame.cpp b/src/HamsterGame.cpp index 234dba5..024a96d 100644 --- a/src/HamsterGame.cpp +++ b/src/HamsterGame.cpp @@ -140,6 +140,7 @@ void HamsterGame::LoadAnimations(){ LoadAnimation(AnimationState::DEFAULT,"checkpoint.png",{{}},0.f,Animate2D::Style::OneShot,{128,128}); LoadAnimation(AnimationState::CHECKPOINT_CYCLING,"checkpoint.png",{{},{128,0}},0.4f,Animate2D::Style::Repeat,{128,128}); LoadAnimation(AnimationState::CHECKPOINT_COLLECTED,"checkpoint.png",{{128,0}},0.f,Animate2D::Style::OneShot,{128,128}); + LoadAnimation(AnimationState::COUNTDOWN,"countdown.png",{{0,0},{32,0},{64,0}},1.f,Animate2D::Style::OneShot,{32,32}); } void HamsterGame::LoadLevel(const std::string&mapName){ @@ -198,9 +199,11 @@ void HamsterGame::LoadLevel(const std::string&mapName){ audio.Play(bgm.at(currentMap.value().GetData().GetBGM()),true); Hamster::MoveHamstersToSpawn(currentMap.value().GetData().GetSpawnZone()); + countdownTimer=3.f; } void HamsterGame::UpdateGame(const float fElapsedTime){ + countdownTimer=std::max(0.f,countdownTimer-fElapsedTime); vEye.z+=(Hamster::GetPlayer().GetZ()+zoom-vEye.z)*fLazyFollowRate*fElapsedTime; speedometerDisplayAmt+=(Hamster::GetPlayer().GetSpeed()-speedometerDisplayAmt)*fLazyFollowRate*fElapsedTime; @@ -308,6 +311,11 @@ void HamsterGame::DrawGame(){ DrawDecal({2.f,4.f},GetGFX("radar.png").Decal()); DrawRadar(); DrawStringDecal({0,8.f},std::to_string(GetFPS())); + if(countdownTimer>0.f){ + Pixel timerColor{fmod(countdownTimer,1.f)<0.5f?GREEN:WHITE}; + timerColor.a=util::lerp(0.f,1.f,fmod(countdownTimer,1.f))*255; + DrawPartialRotatedDecal(SCREEN_FRAME.middle(),GetGFX("countdown.png").Decal(),0.f,{16.f,16.f},{int(countdownTimer)*32.f,0.f},{32,32},{4.f,4.f},timerColor); + } } const Terrain::TerrainType HamsterGame::GetTerrainTypeAtPos(const vf2d pos)const{ @@ -665,6 +673,10 @@ const int HamsterGame::GetRaceTime(){ return net.GetCurrentRaceTime(); } +const bool HamsterGame::RaceCountdownCompleted(){ + return countdownTimer==0.f; +} + int main() { HamsterGame game("Project Hamster"); diff --git a/src/HamsterGame.h b/src/HamsterGame.h index 260dec3..cc8076c 100644 --- a/src/HamsterGame.h +++ b/src/HamsterGame.h @@ -102,6 +102,7 @@ public: static void SavePB(const std::string&mapName,int ms); static void LoadPBs(); const int GetRaceTime(); + const bool RaceCountdownCompleted(); private: void UpdateGame(const float fElapsedTime); void DrawGame(); @@ -141,6 +142,7 @@ private: std::unordered_mapbgm; GameMode mode{GameMode::SINGLE_RACE}; HamsterNet net; + float countdownTimer{}; #ifndef __EMSCRIPTEN__ #ifndef __DEBUG__ SplashScreen splash; diff --git a/src/TODO.txt b/src/TODO.txt index ffe218f..2dad0a9 100644 --- a/src/TODO.txt +++ b/src/TODO.txt @@ -167,6 +167,7 @@ Hamster Jet Landing Sound Powerup Collection Sound Hamster Wheel Boost Sound Checkpoint Collection Sound +Countdown Sound Effect Hamster Jet Launch Command Sound Fail to Boost/Jet Launch command sound