aboutsummaryrefslogtreecommitdiff
path: root/src/example/scene_manager.cpp
diff options
context:
space:
mode:
authorWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-11-18 15:34:22 +0100
committerWBoerenkamps <wrj.boerenkamps@student.avans.nl>2024-11-18 15:34:22 +0100
commitb92da3c729c8fc7c002cb3acbb75c56cb63bd89e (patch)
tree454b64d31b7e0c9151da88a0d49ee782565f49e9 /src/example/scene_manager.cpp
parent8b449e764b5c91cd3cb0c4fa404a290ab295a7ef (diff)
parent121b64b1cb6cfead5814070c8b0185d3d7308095 (diff)
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/events
Diffstat (limited to 'src/example/scene_manager.cpp')
-rw-r--r--src/example/scene_manager.cpp24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/example/scene_manager.cpp b/src/example/scene_manager.cpp
index c48d5e3..accec7d 100644
--- a/src/example/scene_manager.cpp
+++ b/src/example/scene_manager.cpp
@@ -12,29 +12,32 @@ using namespace std;
class ConcreteScene1 : public Scene {
public:
- ConcreteScene1(string name) : Scene(name) {}
+ using Scene::Scene;
void load_scene() {
- GameObject object1(0, "scene_1", "tag_scene_1", Vector2{0, 0}, 0, 1);
- GameObject object2(1, "scene_1", "tag_scene_1", Vector2{1, 0}, 0, 1);
- GameObject object3(2, "scene_1", "tag_scene_1", Vector2{2, 0}, 0, 1);
+ auto & mgr = this->component_manager;
+ GameObject object1 = mgr.new_object("scene_1", "tag_scene_1", Vector2{0, 0}, 0, 1);
+ GameObject object2 = mgr.new_object("scene_1", "tag_scene_1", Vector2{1, 0}, 0, 1);
+ GameObject object3 = mgr.new_object("scene_1", "tag_scene_1", Vector2{2, 0}, 0, 1);
}
};
class ConcreteScene2 : public Scene {
public:
- ConcreteScene2(string name) : Scene(name) {}
+ using Scene::Scene;
void load_scene() {
- GameObject object1(0, "scene_2", "tag_scene_2", Vector2{0, 0}, 0, 1);
- GameObject object2(1, "scene_2", "tag_scene_2", Vector2{0, 1}, 0, 1);
- GameObject object3(2, "scene_2", "tag_scene_2", Vector2{0, 2}, 0, 1);
- GameObject object4(3, "scene_2", "tag_scene_2", Vector2{0, 3}, 0, 1);
+ auto & mgr = this->component_manager;
+ GameObject object1 = mgr.new_object("scene_2", "tag_scene_2", Vector2{0, 0}, 0, 1);
+ GameObject object2 = mgr.new_object("scene_2", "tag_scene_2", Vector2{0, 1}, 0, 1);
+ GameObject object3 = mgr.new_object("scene_2", "tag_scene_2", Vector2{0, 2}, 0, 1);
+ GameObject object4 = mgr.new_object("scene_2", "tag_scene_2", Vector2{0, 3}, 0, 1);
}
};
int main() {
- SceneManager & scene_mgr = SceneManager::get_instance();
+ ComponentManager component_mgr{};
+ SceneManager scene_mgr{component_mgr};
// Add the scenes to the scene manager
scene_mgr.add_scene<ConcreteScene1>("scene1");
@@ -47,7 +50,6 @@ int main() {
scene_mgr.load_next_scene();
// Get the Metadata components of each GameObject of Scene1
- ComponentManager & component_mgr = ComponentManager::get_instance();
vector<reference_wrapper<Metadata>> metadata
= component_mgr.get_components_by_type<Metadata>();