cleanup in States.cc file, Alma och Malin
authorAlma Dejus <almde515@student.liu.se>
Mon, 11 Dec 2023 08:51:46 +0000 (09:51 +0100)
committerAlma Dejus <almde515@student.liu.se>
Mon, 11 Dec 2023 08:51:46 +0000 (09:51 +0100)
src/States.cc

index ab7332ea127487c25fe62efc4e16c38aec0cd3cf..d02c490c2b052206ee57f159af57bce1e81baf60 100644 (file)
@@ -46,10 +46,12 @@ Game_state::Game_state(json& params) :
     helper_texture.loadFromFile(data["game_state_assets"]["helper_file"]);
     map_texture.loadFromFile(data["game_state_assets"]["map_file"]);
 
-    player = std::make_unique<Player>(player_texture, sack_texture, data["player"]);
+    player = std::make_unique<Player>(player_texture, sack_texture, 
+                                      data["player"]);
     helper = std::make_unique<Helper>(helper_texture, data["helper"]);
 
-    enemy = std::make_unique<Main_enemy>(main_enemy_texture, data["main_enemy"]);
+    enemy = std::make_unique<Main_enemy>(main_enemy_texture, 
+                                         data["main_enemy"]);
 
     bottle_texture.loadFromFile(data["game_state_assets"]["kir_file"]);
     YF_texture.loadFromFile(data["game_state_assets"]["YF_file"]);
@@ -62,7 +64,8 @@ void Game_state::update(Context &context)
 {
     if (pause_game)
     {
-        context.saved_game.reset(static_cast<Game_state *>(context.current_state.release()));
+        context.saved_game.reset
+            (static_cast<Game_state *>(context.current_state.release()));
         context.next_state = std::make_unique<Pause_menu>(data);
         pause_game = false;
         return;
@@ -86,16 +89,19 @@ void Game_state::update(Context &context)
     time_since_last_bike += context.time.asSeconds();
     if (time_since_last_bottle >= data["game_constants"]["bottles_per_second"])
     {
-        bottles.push_back(std::make_unique<Bottle>(bottle_texture, data["bottle"]));
+        bottles.push_back
+            (std::make_unique<Bottle>(bottle_texture, data["bottle"]));
         time_since_last_bottle = 0;
     }
-    if (time_since_last_yf >= 1 / static_cast<float>(data["game_constants"]["yf_per_second"]))
+    if (time_since_last_yf >= 1 / 
+        static_cast<float>(data["game_constants"]["yf_per_second"]))
     {
         yf = std::make_unique<YF>(YF_texture, data["yf"]);
         time_since_last_yf = 0;
 
     }
-    if(time_since_last_bike >= 1 / static_cast<float>(data["game_constants"]["bikes_per_second"]))
+    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;