From: Nils Forssén Date: Tue, 28 Nov 2023 12:44:31 +0000 (+0100) Subject: Merge branch 'cykel' X-Git-Url: https://gitweb.forssennils.se/?a=commitdiff_plain;h=b63ad70cf1e21be2d26ec1da97be3a063341bcaf;p=TDDC76_proj.git Merge branch 'cykel' --- b63ad70cf1e21be2d26ec1da97be3a063341bcaf diff --cc src/States.cc index 537fc92,f1457fe..9efb67e --- a/src/States.cc +++ b/src/States.cc @@@ -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(data["game_constants"]["bikes_per_second"])) + { + bike = std::make_unique(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 = false; + return; + } + } void Game_state::render(sf::RenderWindow &window) const