14 auto it = this->scenes_.find(new_scene_name);
16 if(it != this->scenes_.end())
17 this->next_scene_ = it->second;
21 this->next_scene_ = std::move(scene);
22 this->scenes_.insert(std::make_pair(new_scene_name, this->next_scene_));
26 this->scenes_.erase(old_scene_name);
28 this->next_scene_ = std::move(scene);
29 this->scenes_.insert(std::make_pair(new_scene_name, this->next_scene_));
33 auto it = this->scenes_.find(new_scene_name);
35 if(it != this->scenes_.end()) {
36 this->scenes_.erase(old_scene_name);
37 this->next_scene_ = it->second;
50 if (this->next_scene_) {
51 this->scene_ = std::move(this->next_scene_);
54 this->scene_->Update();
58 ClearBackground(WHITE);
60 for (
auto const& [key, val] : this->scene_->actors) {
61 val->sprite()->Update();
63 if(val->sprite()->visible)
static void DrawTexture(const std::shared_ptr< game::core::Sprite > &sprite)
Draw a sprite to the screen. Oriented to the size, position and rotation angle of the sprite object....
std::map< std::string, std::shared_ptr< game::core::Scene > > scenes_
This maps stores all referenced scenes. They can be addressed by their names.
std::shared_ptr< game::core::Scene > next_scene_
Pointer to the next scene to be active. The switch will happen when Update() is called the next time.
void replaceWithNewScene(const std::string &old_scene_name, const std::string &new_scene_name, std::shared_ptr< Scene > scene)
Inserts a new scene into scenes_, sets next_scene_ to the new scene and removes the scene identified ...
const std::map< std::string, std::shared_ptr< game::core::Scene > > & scenes() const
void Draw()
Draws all visible actors of the active scene. Then calls the Draw() method of the active scene.
const std::shared_ptr< game::core::Scene > & scene() const
void switchToScene(const std::string &new_scene_name)
Sets next_scene_ to the scene identified by new_scene_name.
void switchToNewScene(const std::string &new_scene_name, std::shared_ptr< Scene > scene)
Inserts a new scene into scenes_ and sets next_scene_ to the new scene.
void Update()
Changes the active scene if next_scene_ is set. Then calls the update() method of the scene.
void replaceWithExistingScene(const std::string &old_scene_name, const std::string &new_scene_name)
Sets next_scene_ to the existing scene identified by new_scene_name and removes the scene identified ...