#include "Context.h"
#include "constants.h"
- Game_state::Game_state() : game_map{}, player{}, helper{}, pause_game{false}, bottles{}, time_since_last_bottle{0.0f}
+ Game_state::Game_state() : game_map{}, player{}, pause_game{false}, bottles{}, time_since_last_bottle{0.0f}, bottle_texture {}
{
-
- bottles.push_back(std::make_unique<Bottle>());
+ bottle_texture.loadFromFile("assets/kir.png");
}
-void Game_state::update(Context& context)
+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>();
pause_game = false;
return;
}
}
time_since_last_bottle += context.time.asSeconds();
- // std::cout << std::fixed << std::setprecision(3) << time_since_last_bottle << std::endl;
+ std::cout << std::fixed << std::setprecision(3) << time_since_last_bottle << std::endl;
if (time_since_last_bottle >= 2)
{
- if (bottles.size() > 10)
- {
- bottles.erase(bottles.begin());
- }
-
- bottles.push_back(std::make_unique<Bottle>());
- // std::cout << "placed bottle"<< std::endl;
+ bottles.push_back(std::make_unique<Bottle>(bottle_texture));
+ std::cout << "placed bottle"<< std::endl;
time_since_last_bottle = 0;
-
}
game_map.update(context);
player.update(context);