From: Nils Forssén Date: Tue, 21 Nov 2023 13:29:36 +0000 (+0100) Subject: Merged helper_collision X-Git-Url: https://gitweb.forssennils.se/?a=commitdiff_plain;h=d0bf276c82c9c4d347f21032ee557de678b731e3;p=TDDC76_proj.git Merged helper_collision --- d0bf276c82c9c4d347f21032ee557de678b731e3 diff --cc assets/data.json index f123922,f3899b2..5ed7ec8 --- a/assets/data.json +++ b/assets/data.json @@@ -22,9 -22,10 +22,15 @@@ { "bottles_per_second" : 2 }, + "map": + { + "points_pos": [100, 100], + "font_size": 24 ++ }, + + "main_enemy": + { + "scale" : [0.35, 0.35] } + } diff --cc src/States.cc index 6c20417,53a6a87..bc0f239 --- a/src/States.cc +++ b/src/States.cc @@@ -14,8 -14,8 +14,9 @@@ Game_state::Game_state() game_map{}, pause_game{false}, player{}, - bottles{}, - main_enemy_texture{}, + bottles{}, + helper{}, ++ main_enemy_texture{}, time_since_last_bottle{0.0f}, bottle_texture {}, data{}, @@@ -28,9 -28,10 +30,11 @@@ player = std::make_unique(data["player"]); helper = std::make_unique(data["helper"]); + game_map = std::make_unique(data["map"]); + enemy = std::make_unique(main_enemy_texture, data["main_enemy"]); bottle_texture.loadFromFile("assets/kir.png"); + } void Game_state::update(Context &context) @@@ -92,15 -81,17 +96,17 @@@ std::cout << "placed bottle"<< std::endl; time_since_last_bottle = 0; } - game_map.update(context); + game_map->update(points); - enemy.update(context); + player->update(context); + helper->update(context); + enemy->update(context); } void Game_state::render(sf::RenderWindow &window) const { - game_map.render(window); + game_map->render(window); player->render(window); - enemy.render(window); + enemy->render(window); helper->render(window); for (int i{}; i < int(bottles.size()); ++i) { diff --cc src/States.h index 379c648,5479aa8..1c8c148 --- a/src/States.h +++ b/src/States.h @@@ -42,14 -42,15 +42,16 @@@ protected private: float time_since_last_bottle; - Map game_map; + std::unique_ptr game_map; std::unique_ptr player; std::unique_ptr helper; - Main_enemy enemy; + std::unique_ptr enemy; + bool pause_game; sf::Texture bottle_texture; + sf::Texture main_enemy_texture; json data; + int points; };