Merge branch 'cykel'
authorNils Forssén <nilfo359@student.liu.se>
Tue, 28 Nov 2023 12:44:31 +0000 (13:44 +0100)
committerNils Forssén <nilfo359@student.liu.se>
Tue, 28 Nov 2023 12:44:31 +0000 (13:44 +0100)
1  2 
src/States.cc
src/States.h

diff --cc src/States.cc
index 537fc92466c53e75f1352c7c6ab5bcc792738082,f1457fe9f04230670a2403a86e00c3232df616d2..9efb67e4a380538c70cdd4152a314a617b7133c2
@@@ -128,23 -128,22 +129,29 @@@ void Game_state::update(Context &contex
          time_since_last_yf = 0;
  
      }
+     if(time_since_last_bike >= 1 / static_cast<float>(data["game_constants"]["bikes_per_second"]))
+     {
+         bike = std::make_unique<Bike_enemy>(bike_texture, data["bike_enemy"]);
+         time_since_last_bike = 0;
+     }
      enemy->update(context);
      game_map->update(points, remaining_time);
-     if (yf.size()>0)
+     if (yf != nullptr)
      {
-         for(unsigned int i {0}; i < yf.size(); ++i)
-         {
-             yf[i]->update(context);
-         }
+         yf->update(context);
+     }
+     if(bike != nullptr)
+     {
+         bike->update(context);
      }
      
 +    if (gameover)
 +    {
 +        context.next_state = std::make_unique<GameOver_menu>();
 +        gameover = false;
 +        return;
 +    }
 +    
  }
  
  void Game_state::render(sf::RenderWindow &window) const
diff --cc src/States.h
Simple merge