diff --git a/assets/PBData b/assets/PBData index bc5a9bb..92625dc 100644 --- a/assets/PBData +++ b/assets/PBData @@ -1 +1 @@ -2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 0.7 0.6 OneLoneHam Black \ No newline at end of file +44669 64212 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 2147483647 0.7 0.6 OneLoneHam Black \ No newline at end of file diff --git a/assets/button3.png b/assets/button3.png index f65f7da..bb9e6b2 100644 Binary files a/assets/button3.png and b/assets/button3.png differ diff --git a/assets/highlight_button3.png b/assets/highlight_button3.png index b4c9646..90c5135 100644 Binary files a/assets/highlight_button3.png and b/assets/highlight_button3.png differ diff --git a/assets/sounds/cannot_launch_jet.wav b/assets/sounds/cannot_launch_jet.wav new file mode 100644 index 0000000..54f5eb1 Binary files /dev/null and b/assets/sounds/cannot_launch_jet.wav differ diff --git a/assets/sounds/checkpoint_collection.wav b/assets/sounds/checkpoint_collection.wav new file mode 100644 index 0000000..88feede Binary files /dev/null and b/assets/sounds/checkpoint_collection.wav differ diff --git a/assets/sounds/collect_powerup.wav b/assets/sounds/collect_powerup.wav new file mode 100644 index 0000000..a1f8aa7 Binary files /dev/null and b/assets/sounds/collect_powerup.wav differ diff --git a/assets/sounds/countdown.wav b/assets/sounds/countdown.wav new file mode 100644 index 0000000..3cb78e8 Binary files /dev/null and b/assets/sounds/countdown.wav differ diff --git a/assets/sounds/drown_burn.wav b/assets/sounds/drown_burn.wav new file mode 100644 index 0000000..9617edd Binary files /dev/null and b/assets/sounds/drown_burn.wav differ diff --git a/assets/sounds/hit_hamster.wav b/assets/sounds/hit_hamster.wav new file mode 100644 index 0000000..7559fda Binary files /dev/null and b/assets/sounds/hit_hamster.wav differ diff --git a/assets/sounds/hit_hamster_2.wav b/assets/sounds/hit_hamster_2.wav new file mode 100644 index 0000000..0d7a020 Binary files /dev/null and b/assets/sounds/hit_hamster_2.wav differ diff --git a/assets/sounds/jet_land.wav b/assets/sounds/jet_land.wav new file mode 100644 index 0000000..ffaf07f Binary files /dev/null and b/assets/sounds/jet_land.wav differ diff --git a/assets/sounds/menu_hover.wav b/assets/sounds/menu_hover.wav new file mode 100644 index 0000000..8f16cc1 Binary files /dev/null and b/assets/sounds/menu_hover.wav differ diff --git a/assets/sounds/menu_set_name.wav b/assets/sounds/menu_set_name.wav new file mode 100644 index 0000000..0ae70b6 Binary files /dev/null and b/assets/sounds/menu_set_name.wav differ diff --git a/assets/sounds/obtain_jet.wav b/assets/sounds/obtain_jet.wav new file mode 100644 index 0000000..1df839c Binary files /dev/null and b/assets/sounds/obtain_jet.wav differ diff --git a/assets/sounds/select_track_confirm_name_menu.wav b/assets/sounds/select_track_confirm_name_menu.wav new file mode 100644 index 0000000..b1e02be Binary files /dev/null and b/assets/sounds/select_track_confirm_name_menu.wav differ diff --git a/assets/sounds/sfx_movement_footsteps1a.wav b/assets/sounds/sfx_movement_footsteps1a.wav new file mode 100644 index 0000000..3010817 Binary files /dev/null and b/assets/sounds/sfx_movement_footsteps1a.wav differ diff --git a/assets/sounds/sfx_movement_footsteps1b.wav b/assets/sounds/sfx_movement_footsteps1b.wav new file mode 100644 index 0000000..fa1b3ec Binary files /dev/null and b/assets/sounds/sfx_movement_footsteps1b.wav differ diff --git a/assets/sounds/sfx_sounds_falling7.wav b/assets/sounds/sfx_sounds_falling7.wav new file mode 100644 index 0000000..0fdafe6 Binary files /dev/null and b/assets/sounds/sfx_sounds_falling7.wav differ diff --git a/assets/sounds/start_race_whistle.wav b/assets/sounds/start_race_whistle.wav new file mode 100644 index 0000000..314ba54 Binary files /dev/null and b/assets/sounds/start_race_whistle.wav differ diff --git a/assets/sounds/wheel_boost.wav b/assets/sounds/wheel_boost.wav new file mode 100644 index 0000000..869b7a9 Binary files /dev/null and b/assets/sounds/wheel_boost.wav differ diff --git a/src/Hamster.cpp b/src/Hamster.cpp index 1dc9f4b..792cbd6 100644 --- a/src/Hamster.cpp +++ b/src/Hamster.cpp @@ -231,9 +231,9 @@ void Hamster::CreateHamsters(const HamsterGame::GameMode mode){ playerHamster.reset(); HAMSTER_LIST.reserve(MAX_HAMSTER_COUNT); if(NPC_HAMSTER_COUNT+1>MAX_HAMSTER_COUNT)throw std::runtime_error{std::format("WARNING! Max hamster count is too high! Please expand the MAX_HAMSTER_COUNT if you want more hamsters. Requested {} hamsters.",MAX_HAMSTER_COUNT)}; - playerHamster=&HAMSTER_LIST.emplace_back(vf2d{},HamsterGame::Game().GetPlayerHamsterImage(),PLAYER_CONTROLLED); + playerHamster=&HAMSTER_LIST.emplace_back(vf2d{},HamsterGame::Game().ColorToHamsterImage(HamsterGame::Game().hamsterColor),PLAYER_CONTROLLED); std::vectorhamsterColorChoices{NPC_HAMSTER_IMAGES}; - std::erase(hamsterColorChoices,HamsterGame::Game().GetPlayerHamsterImage()); + std::erase(hamsterColorChoices,HamsterGame::Game().ColorToHamsterImage(HamsterGame::Game().hamsterColor)); for(int i:std::ranges::iota_view(0U,NPC_HAMSTER_COUNT)){ std::string colorChoice{hamsterColorChoices.at(util::random()%hamsterColorChoices.size())}; std::erase(hamsterColorChoices,colorChoice); @@ -848,8 +848,9 @@ void Hamster::HandleAIControls(){ vf2d aimingDir{}; const HamsterAI::ActionOptRef¤tAction{ai.GetCurrentAction()}; + HamsterAI::Action action; if(!currentAction.has_value()){temporaryNode=ai.GetPreviousAction().value().get().pos;} - const HamsterAI::Action&action{currentAction.value().get()}; + else action=currentAction.value().get(); if(aiNodeTime>GetAIAdjustNodeTime()){ geom2d::lineplayerToHamster{GetPlayer().GetPos(),GetPos()}; diff --git a/src/HamsterAI.cpp b/src/HamsterAI.cpp index c81b20a..a1af4dc 100644 --- a/src/HamsterAI.cpp +++ b/src/HamsterAI.cpp @@ -134,6 +134,7 @@ void HamsterAI::OnJetBeginLanding(const vi2d pos){ const HamsterAI::ActionOptRef HamsterAI::GetPreviousAction(){ if(actionInd-1>0)return actionsToPerform[actionInd-1]; + if(actionsToPerform.size()>0)return actionsToPerform[actionsToPerform.size()-1]; return {}; } const HamsterAI::ActionOptRef HamsterAI::RevertToPreviousAction(){ diff --git a/src/HamsterGame.cpp b/src/HamsterGame.cpp index b232359..ddc9b20 100644 --- a/src/HamsterGame.cpp +++ b/src/HamsterGame.cpp @@ -772,8 +772,8 @@ void HamsterGame::QuitGame(){ gameIsRunning=false; } -const std::string&HamsterGame::GetPlayerHamsterImage()const{ - return std::format("hamster{}.png",std::distance(hamsterColorNames.begin(),std::find(hamsterColorNames.begin(),hamsterColorNames.end(),hamsterColor))+1); +const std::string HamsterGame::ColorToHamsterImage(const std::string&color)const{ + return std::format("hamster{}.png",std::distance(hamsterColorNames.begin(),std::find(hamsterColorNames.begin(),hamsterColorNames.end(),color))+1); } int main() diff --git a/src/HamsterGame.h b/src/HamsterGame.h index 3ebd55a..8a57acb 100644 --- a/src/HamsterGame.h +++ b/src/HamsterGame.h @@ -78,6 +78,17 @@ public: HamsterGame(const std::string&appName); static geom2d::rectSCREEN_FRAME; TransformedView tv{}; +private: + std::vectorhamsterColorNames{ + "Yellow", + "Pink", + "Cyan", + "Black", + "Green", + "Purple" + "Red", + "Blue", + }; public: bool OnUserCreate()override final; bool OnUserUpdate(float fElapsedTime)override final; @@ -114,7 +125,8 @@ public: void QuitGame(); std::string playerName{"OneLoneHamster"}; void SaveOptions(); - const std::string&GetPlayerHamsterImage()const; + const std::string ColorToHamsterImage(const std::string&color)const; + std::string hamsterColor{hamsterColorNames[0]}; private: void UpdateGame(const float fElapsedTime); void DrawGame(); @@ -160,16 +172,6 @@ private: #endif #endif bool netInitialized{false}; - std::vectorhamsterColorNames{ - "Yellow", - "Pink", - "Cyan", - "Black", - "Green", - "Purple" - "Red", - "Blue", - }; std::vectormapNameList{ "StageI.tmx", "StageII.tmx", @@ -205,5 +207,4 @@ private: std::string hamsterColorLabel{"hamsterColor"}; float bgmVol{0.7f}; float sfxVol{0.7f}; - std::string hamsterColor{hamsterColorNames[0]}; }; diff --git a/src/Menu.cpp b/src/Menu.cpp index b581704..41854f7 100644 --- a/src/Menu.cpp +++ b/src/Menu.cpp @@ -130,12 +130,62 @@ std::vectorMenu::GetMenuButtons(const MenuType type){ buttons.emplace_back(HamsterGame::SCREEN_FRAME.size/2+vf2d{0.f,64.f},"Quit","button.png","highlight_button.png",Pixel{165,208,96},Pixel{37,134,139},[this](Button&self){Transition(SHIFT_DOWN,QUIT,0.5f);}); }break; case GRAND_PRIX:{ - //Add more buttons up here! + buttons.emplace_back(HamsterGame::SCREEN_FRAME.pos+vf2d{60.f,HamsterGame::SCREEN_FRAME.size.y/2-36.f},"Grand Prix I - ","longbutton2.png","longhighlight_button2.png",Pixel{114,109,163},Pixel{79,81,128},[this](Button&self){ + selectedMap="StageI.tmx"; + Transition(FADE_OUT,LOADING,0.5f); + }); buttons.emplace_back(vf2d{54.f,HamsterGame::SCREEN_FRAME.size.y-24.f},"< Back","button3.png","highlight_button3.png",Pixel{145,199,255},Pixel{145,199,255},[this](Button&self){Transition(SHIFT_RIGHT,MAIN_MENU,0.5f);}); }break; case SINGLE_RACE:{ - //Add more buttons up here! - buttons.emplace_back(vf2d{54.f,HamsterGame::SCREEN_FRAME.size.y-24.f},"< Back","button4.png","highlight_button4.png",Pixel{220,185,155},Pixel{180,140,152},[this](Button&self){Transition(SHIFT_DOWN,MAIN_MENU,0.5f);}); + buttons.emplace_back(HamsterGame::SCREEN_FRAME.size/2+vf2d{0.f,-132.f},"I - Welcome to Hamster Planet!","longbutton2.png","longhighlight_button2.png",Pixel{114,109,163},Pixel{79,81,128},[this](Button&self){ + selectedMap="StageI.tmx"; + Transition(FADE_OUT,LOADING,0.5f); + }); + buttons.emplace_back(HamsterGame::SCREEN_FRAME.size/2+vf2d{0.f,-132.f+22.f*1},"II - Splitting Hairs","longbutton2.png","longhighlight_button2.png",Pixel{114,109,163},Pixel{79,81,128},[this](Button&self){ + selectedMap="StageII.tmx"; + Transition(FADE_OUT,LOADING,0.5f); + }); + buttons.emplace_back(HamsterGame::SCREEN_FRAME.size/2+vf2d{0.f,-132.f+22.f*2},"III - The Stranger Lands","longbutton2.png","longhighlight_button2.png",Pixel{114,109,163},Pixel{79,81,128},[this](Button&self){ + selectedMap="StageIII.tmx"; + Transition(FADE_OUT,LOADING,0.5f); + }); + buttons.emplace_back(HamsterGame::SCREEN_FRAME.size/2+vf2d{0.f,-132.f+22.f*3},"IV - Jet Jet Go!","longbutton2.png","longhighlight_button2.png",Pixel{114,109,163},Pixel{79,81,128},[this](Button&self){ + selectedMap="StageIV.tmx"; + Transition(FADE_OUT,LOADING,0.5f); + }); + buttons.emplace_back(HamsterGame::SCREEN_FRAME.size/2+vf2d{0.f,-132.f+22.f*4},"V - Run Run Run!","longbutton2.png","longhighlight_button2.png",Pixel{114,109,163},Pixel{79,81,128},[this](Button&self){ + selectedMap="StageV.tmx"; + Transition(FADE_OUT,LOADING,0.5f); + }); + buttons.emplace_back(HamsterGame::SCREEN_FRAME.size/2+vf2d{0.f,-132.f+22.f*5},"VI - A Twisty Maze","longbutton2.png","longhighlight_button2.png",Pixel{114,109,163},Pixel{79,81,128},[this](Button&self){ + selectedMap="StageVI.tmx"; + Transition(FADE_OUT,LOADING,0.5f); + }); + buttons.emplace_back(HamsterGame::SCREEN_FRAME.size/2+vf2d{0.f,-132.f+22.f*6},"VII - Dunescape","longbutton2.png","longhighlight_button2.png",Pixel{114,109,163},Pixel{79,81,128},[this](Button&self){ + selectedMap="StageVII.tmx"; + Transition(FADE_OUT,LOADING,0.5f); + }); + buttons.emplace_back(HamsterGame::SCREEN_FRAME.size/2+vf2d{0.f,-132.f+22.f*7},"VIII - Swamps of Travesty","longbutton2.png","longhighlight_button2.png",Pixel{114,109,163},Pixel{79,81,128},[this](Button&self){ + selectedMap="StageVIII.tmx"; + Transition(FADE_OUT,LOADING,0.5f); + }); + buttons.emplace_back(HamsterGame::SCREEN_FRAME.size/2+vf2d{0.f,-132.f+22.f*8},"IX - Wide Chasm","longbutton2.png","longhighlight_button2.png",Pixel{114,109,163},Pixel{79,81,128},[this](Button&self){ + selectedMap="StageIX.tmx"; + Transition(FADE_OUT,LOADING,0.5f); + }); + buttons.emplace_back(HamsterGame::SCREEN_FRAME.size/2+vf2d{0.f,-132.f+22.f*9},"X - Hamster Island","longbutton2.png","longhighlight_button2.png",Pixel{114,109,163},Pixel{79,81,128},[this](Button&self){ + selectedMap="StageX.tmx"; + Transition(FADE_OUT,LOADING,0.5f); + }); + buttons.emplace_back(HamsterGame::SCREEN_FRAME.size/2+vf2d{0.f,-132.f+22.f*10},"XI - Lava Panic!","longbutton2.png","longhighlight_button2.png",Pixel{114,109,163},Pixel{79,81,128},[this](Button&self){ + selectedMap="StageXI.tmx"; + Transition(FADE_OUT,LOADING,0.5f); + }); + buttons.emplace_back(HamsterGame::SCREEN_FRAME.size/2+vf2d{0.f,-132.f+22.f*11},"XII - The Great Plunge","longbutton2.png","longhighlight_button2.png",Pixel{114,109,163},Pixel{79,81,128},[this](Button&self){ + selectedMap="StageXII.tmx"; + Transition(FADE_OUT,LOADING,0.5f); + }); + buttons.emplace_back(vf2d{54.f,HamsterGame::SCREEN_FRAME.size.y-12.f},"< Back","button4.png","highlight_button4.png",Pixel{220,185,155},Pixel{180,140,152},[this](Button&self){Transition(SHIFT_DOWN,MAIN_MENU,0.5f);}); }break; case OPTIONS:{ buttons.emplace_back(HamsterGame::SCREEN_FRAME.size/2+vf2d{0.f,-32.f},std::format("BGM: {}",int(round(HamsterGame::Game().bgmVol*100))),"button2.png","highlight_button2.png",Pixel{114,109,163},Pixel{79,81,128},[this](Button&self){ @@ -302,6 +352,41 @@ void Menu::Draw(HamsterGame&game,const MenuType menu,const vi2d pos){ game.DrawPartialDecal(vi2d{pos},game.SCREEN_FRAME.size,game.GetGFX("background4.png").Decal(),vf2d{}+int(game.GetRuntime()*4),game.SCREEN_FRAME.size); DrawButtons(pos); game.border.Draw(); + if(selectedButton.value()::max())timerStr=util::timerStr(game.mapPBs[mapName]); + vf2d timerStrSize{game.GetTextSize(timerStr)*vf2d{1.f,2.f}}; + game.DrawShadowRotatedStringDecal({48.f,44.f},timerStr,0.f,timerStrSize/2,WHITE,BLACK,{1.f,2.f}); + if(lastHovered!=selectedButton.value()){ + loadedLeaderboard.clear(); + loadedLeaderboard=game.net.GetLeaderboard(mapName); + lastHovered=selectedButton.value(); + } + if(loadedLeaderboard.size()>0){ + game.DrawShadowStringPropDecal(vf2d{game.SCREEN_FRAME.pos.x+game.SCREEN_FRAME.size.x,0.f}+vf2d{4.f,4.f},"Leaderboard",YELLOW,BLACK,{1.f,1.f}); + for(int i=0;itotalPixelSpaceForName){ + float nameScaleX{totalPixelSpaceForName/entryStrSize.x}; + game.DrawShadowStringPropDecal(vf2d{game.SCREEN_FRAME.pos.x+game.SCREEN_FRAME.size.x,0.f}+vf2d{4.f+placementStrSize.x,4.f+(i+1)*20.f},std::format("{}",entry.name,util::timerStr(entry.time)),WHITE,BLACK,{nameScaleX,1.f}); + }else game.DrawShadowStringPropDecal(vf2d{game.SCREEN_FRAME.pos.x+game.SCREEN_FRAME.size.x,0.f}+vf2d{4.f+placementStrSize.x,4.f+(i+1)*20.f},std::format("{}",entry.name,util::timerStr(entry.time)),WHITE,BLACK,{1.f,1.f}); + game.DrawShadowStringPropDecal(vf2d{game.SCREEN_FRAME.pos.x+game.SCREEN_FRAME.size.x,0.f}+vf2d{4.f+placementStrSize.x+4.f,4.f+(i+1)*20.f+10.f},std::format("{}",util::timerStr(entry.time)),WHITE,BLACK,{1.f,1.f}); + + std::string hamsterDisplayImg{game.ColorToHamsterImage(entry.color)}; + game.DrawPartialRotatedDecal(vf2d{game.SCREEN_FRAME.pos.x+game.SCREEN_FRAME.size.x,0.f}+vf2d{96.f-6.f,4.f+(i+1)*20.f+2.f},game.GetGFX(hamsterDisplayImg).Decal(),0.f,{8.f,6.f},{64.f,64.f},{16.f,12.f},{-1.f,1.f}); + } + } + } }break; case OPTIONS:{ game.DrawPartialDecal(vi2d{pos},game.SCREEN_FRAME.size,game.GetGFX("background2.png").Decal(),vf2d{}+int(game.GetRuntime()*4),game.SCREEN_FRAME.size); diff --git a/src/Menu.h b/src/Menu.h index 46bb354..677022c 100644 --- a/src/Menu.h +++ b/src/Menu.h @@ -39,6 +39,7 @@ All rights reserved. #include "olcPixelGameEngine.h" #include +#include "HamsterNet.h" class HamsterGame; class Menu{ @@ -98,12 +99,14 @@ class Menu{ std::vector