From b2f0190f6b2a227a21dd4909476171f7cc371a2d Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 19 Mar 2022 16:46:19 -0400 Subject: menu! --- src/game.cpp | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) (limited to 'src/game.cpp') diff --git a/src/game.cpp b/src/game.cpp index f8508c2..501722d 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -12,6 +12,7 @@ Game::Game(std::mt19937& rng, Muxer& muxer, Renderer& renderer) : rng(rng), muxer(muxer), + renderer(renderer), sign(renderer.getFont()) { losePopLampTimer.accumulate(losePopLampTimer.getDt()); @@ -740,13 +741,7 @@ void Game::updatePlaying(size_t frameTime) { { if (e.type == SDL_QUIT) { - if (losing != LoseState::None) - { - quit = true; - } else { - losing = LoseState::PoppingLamps; - muxer.stopMusic(); - } + quit = true; } else if (e.type == SDL_KEYDOWN) { switch (e.key.keysym.sym) @@ -755,10 +750,13 @@ void Game::updatePlaying(size_t frameTime) { { if (losing != LoseState::None) { - quit = true; + if (quitting) { + quit = true; + } else { + losing = LoseState::Done; + } } else { - losing = LoseState::PoppingLamps; - muxer.stopMusic(); + menu.open(*this); } break; @@ -922,11 +920,21 @@ void Game::updatePlaying(size_t frameTime) { { if (numDust == 0) { - quit = true; + if (quitting) { + quit = true; + } else { + losing = LoseState::Done; + } } break; } + + case LoseState::Done: + { + // Do nothing. + break; + } } switch (signInstructionState) { @@ -1035,7 +1043,9 @@ void Game::updatePlaying(size_t frameTime) { } void Game::update(size_t frameTime) { - if (sign.signDisplayState != SignInstructionState::Hidden) { + if (menu.menuState != MenuState::Closed) { + menu.update(frameTime, *this); + } else if (sign.signDisplayState != SignInstructionState::Hidden) { sign.update(frameTime, *this); } else { updatePlaying(frameTime); -- cgit 1.4.1