Fixed game_over
authorNils Forssén <nilfo359@student.liu.se>
Tue, 28 Nov 2023 12:48:39 +0000 (13:48 +0100)
committerNils Forssén <nilfo359@student.liu.se>
Tue, 28 Nov 2023 12:48:39 +0000 (13:48 +0100)
src/States.cc
src/States.h

index 9efb67e4a380538c70cdd4152a314a617b7133c2..861618628c6929b922ada5842629bc2b859eaa1c 100644 (file)
@@ -14,7 +14,6 @@ using json = nlohmann::json;
 Game_state::Game_state() : 
     game_map{}, 
     pause_game{false},
-    gameover{false},
     player{},
     bottles{}, 
     helper{},
@@ -62,7 +61,7 @@ void Game_state::update(Context &context)
     int remaining_time {static_cast<int>(data["game_constants"]["game_time"]) - static_cast<int>(game_time)};
     if (remaining_time < 0)
     {
-        context.next_state = std::make_unique<Start_menu>();
+        context.next_state = std::make_unique<GameOver_menu>();
         return;
     }
  
@@ -145,13 +144,6 @@ void Game_state::update(Context &context)
         bike->update(context);
     }
     
-    if (gameover)
-    {
-        context.next_state = std::make_unique<GameOver_menu>();
-        gameover = false;
-        return;
-    }
-    
 }
 
 void Game_state::render(sf::RenderWindow &window) const
@@ -188,11 +180,6 @@ void Game_state::handle_input(sf::Event &event)
             pause_game = true;
             return;
             break;
-
-        case  sf::Keyboard::T:
-            gameover = true;
-            break;
-
         default:
             break;
         }
index 450f0497f27f6e102d9ca18d8cd4927232df6554..9e7505c76c3b3cacf22d529b827481bb97a31a28 100644 (file)
@@ -63,8 +63,6 @@ private:
     
     json data;
     int points;
-
-    bool gameover;
 };
 
 class Start_menu : public State