summary refs log tree commit diff stats
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp34
1 files changed, 22 insertions, 12 deletions
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 @@
12Game::Game(std::mt19937& rng, Muxer& muxer, Renderer& renderer) : 12Game::Game(std::mt19937& rng, Muxer& muxer, Renderer& renderer) :
13 rng(rng), 13 rng(rng),
14 muxer(muxer), 14 muxer(muxer),
15 renderer(renderer),
15 sign(renderer.getFont()) 16 sign(renderer.getFont())
16{ 17{
17 losePopLampTimer.accumulate(losePopLampTimer.getDt()); 18 losePopLampTimer.accumulate(losePopLampTimer.getDt());
@@ -740,13 +741,7 @@ void Game::updatePlaying(size_t frameTime) {
740 { 741 {
741 if (e.type == SDL_QUIT) 742 if (e.type == SDL_QUIT)
742 { 743 {
743 if (losing != LoseState::None) 744 quit = true;
744 {
745 quit = true;
746 } else {
747 losing = LoseState::PoppingLamps;
748 muxer.stopMusic();
749 }
750 } else if (e.type == SDL_KEYDOWN) 745 } else if (e.type == SDL_KEYDOWN)
751 { 746 {
752 switch (e.key.keysym.sym) 747 switch (e.key.keysym.sym)
@@ -755,10 +750,13 @@ void Game::updatePlaying(size_t frameTime) {
755 { 750 {
756 if (losing != LoseState::None) 751 if (losing != LoseState::None)
757 { 752 {
758 quit = true; 753 if (quitting) {
754 quit = true;
755 } else {
756 losing = LoseState::Done;
757 }
759 } else { 758 } else {
760 losing = LoseState::PoppingLamps; 759 menu.open(*this);
761 muxer.stopMusic();
762 } 760 }
763 761
764 break; 762 break;
@@ -922,11 +920,21 @@ void Game::updatePlaying(size_t frameTime) {
922 { 920 {
923 if (numDust == 0) 921 if (numDust == 0)
924 { 922 {
925 quit = true; 923 if (quitting) {
924 quit = true;
925 } else {
926 losing = LoseState::Done;
927 }
926 } 928 }
927 929
928 break; 930 break;
929 } 931 }
932
933 case LoseState::Done:
934 {
935 // Do nothing.
936 break;
937 }
930 } 938 }
931 939
932 switch (signInstructionState) { 940 switch (signInstructionState) {
@@ -1035,7 +1043,9 @@ void Game::updatePlaying(size_t frameTime) {
1035} 1043}
1036 1044
1037void Game::update(size_t frameTime) { 1045void Game::update(size_t frameTime) {
1038 if (sign.signDisplayState != SignInstructionState::Hidden) { 1046 if (menu.menuState != MenuState::Closed) {
1047 menu.update(frameTime, *this);
1048 } else if (sign.signDisplayState != SignInstructionState::Hidden) {
1039 sign.update(frameTime, *this); 1049 sign.update(frameTime, *this);
1040 } else { 1050 } else {
1041 updatePlaying(frameTime); 1051 updatePlaying(frameTime);