From: Alma Dejus Date: Mon, 11 Dec 2023 08:51:46 +0000 (+0100) Subject: cleanup in States.cc file, Alma och Malin X-Git-Url: https://gitweb.forssennils.se/?a=commitdiff_plain;h=7bfb7bc365d7238be14231b6afffaeebe8ec93a0;p=TDDC76_proj.git cleanup in States.cc file, Alma och Malin --- diff --git a/src/States.cc b/src/States.cc index ab7332e..d02c490 100644 --- a/src/States.cc +++ b/src/States.cc @@ -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_texture, sack_texture, data["player"]); + player = std::make_unique(player_texture, sack_texture, + data["player"]); helper = std::make_unique(helper_texture, data["helper"]); - enemy = std::make_unique(main_enemy_texture, data["main_enemy"]); + enemy = std::make_unique(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(context.current_state.release())); + context.saved_game.reset + (static_cast(context.current_state.release())); context.next_state = std::make_unique(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_texture, data["bottle"])); + bottles.push_back + (std::make_unique(bottle_texture, data["bottle"])); time_since_last_bottle = 0; } - if (time_since_last_yf >= 1 / static_cast(data["game_constants"]["yf_per_second"])) + if (time_since_last_yf >= 1 / + static_cast(data["game_constants"]["yf_per_second"])) { yf = std::make_unique(YF_texture, data["yf"]); time_since_last_yf = 0; } - if(time_since_last_bike >= 1 / static_cast(data["game_constants"]["bikes_per_second"])) + if(time_since_last_bike >= 1 / + static_cast(data["game_constants"]["bikes_per_second"])) { bike = std::make_unique(bike_texture, data["bike_enemy"]); time_since_last_bike = 0;