diff options
author | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-16 15:26:54 +0100 |
---|---|---|
committer | WBoerenkamps <wrj.boerenkamps@student.avans.nl> | 2024-11-16 15:26:54 +0100 |
commit | 6b3feac981ce78144fb69e490640a4b07dd29f1d (patch) | |
tree | 88c9a7b1b03ada97a8152591deb035681f99b7c8 /src/example | |
parent | 8209678e20605936b2ce58331c1a65d8f23fee91 (diff) | |
parent | 9f6475e7b0698c414138e2a8140b47f01ce9c5d1 (diff) |
Merge branch 'master' of https://github.com/lonkaars/crepe into wouter/events
Diffstat (limited to 'src/example')
-rw-r--r-- | src/example/asset_manager.cpp | 13 | ||||
-rw-r--r-- | src/example/audio_internal.cpp | 3 | ||||
-rw-r--r-- | src/example/components_internal.cpp | 6 | ||||
-rw-r--r-- | src/example/ecs.cpp | 13 | ||||
-rw-r--r-- | src/example/particles.cpp | 3 | ||||
-rw-r--r-- | src/example/proxy.cpp | 3 | ||||
-rw-r--r-- | src/example/rendering.cpp | 10 | ||||
-rw-r--r-- | src/example/scene_manager.cpp | 4 | ||||
-rw-r--r-- | src/example/script.cpp | 3 |
9 files changed, 24 insertions, 34 deletions
diff --git a/src/example/asset_manager.cpp b/src/example/asset_manager.cpp index cf64f89..917b547 100644 --- a/src/example/asset_manager.cpp +++ b/src/example/asset_manager.cpp @@ -6,18 +6,17 @@ using namespace crepe; int main() { - // this needs to be called before the asset manager otherwise the destructor - // of sdl is not in the right order + // this needs to be called before the asset manager otherwise the destructor of sdl is not in + // the right order { Texture test("../asset/texture/img.png"); } - // FIXME: make it so the issue described by the above comment is not possible - // (i.e. the order in which internal classes are instantiated should not - // impact the way the engine works). + // FIXME: make it so the issue described by the above comment is not possible (i.e. the order + // in which internal classes are instantiated should not impact the way the engine works). auto & mgr = AssetManager::get_instance(); { - // TODO: [design] the Sound class can't be directly included by the user as - // it includes SoLoud headers. + // TODO: [design] the Sound class can't be directly included by the user as it includes + // SoLoud headers. auto bgm = mgr.cache<Sound>("../mwe/audio/bgm.ogg"); auto sfx1 = mgr.cache<Sound>("../mwe/audio/sfx1.wav"); auto sfx2 = mgr.cache<Sound>("../mwe/audio/sfx2.wav"); diff --git a/src/example/audio_internal.cpp b/src/example/audio_internal.cpp index 1ea839d..81f8980 100644 --- a/src/example/audio_internal.cpp +++ b/src/example/audio_internal.cpp @@ -34,8 +34,7 @@ int main() { // Start the background track bgm.play(); - // Play each sample sequentially while pausing and resuming the background - // track + // Play each sample sequentially while pausing and resuming the background track this_thread::sleep_for(500ms); sfx1.play(); this_thread::sleep_for(500ms); diff --git a/src/example/components_internal.cpp b/src/example/components_internal.cpp index ea1eaad..1f8884d 100644 --- a/src/example/components_internal.cpp +++ b/src/example/components_internal.cpp @@ -49,10 +49,8 @@ int main() { delete game_object[i]; } - auto add_time = chrono::duration_cast<chrono::microseconds>(stop_adding - - start_adding); - auto loop_time = chrono::duration_cast<chrono::microseconds>(stop_looping - - stop_adding); + auto add_time = chrono::duration_cast<chrono::microseconds>(stop_adding - start_adding); + auto loop_time = chrono::duration_cast<chrono::microseconds>(stop_looping - stop_adding); printf("add time: %ldus\n", add_time.count()); printf("loop time: %ldus\n", loop_time.count()); diff --git a/src/example/ecs.cpp b/src/example/ecs.cpp index e61c398..3197100 100644 --- a/src/example/ecs.cpp +++ b/src/example/ecs.cpp @@ -31,24 +31,21 @@ int main() { // Get the Metadata and Transform components of each GameObject ComponentManager & mgr = ComponentManager::get_instance(); - vector<reference_wrapper<Metadata>> metadata - = mgr.get_components_by_type<Metadata>(); - vector<reference_wrapper<Transform>> transform - = mgr.get_components_by_type<Transform>(); + vector<reference_wrapper<Metadata>> metadata = mgr.get_components_by_type<Metadata>(); + vector<reference_wrapper<Transform>> transform = mgr.get_components_by_type<Transform>(); // Print the Metadata and Transform components for (auto & m : metadata) { cout << "Id: " << m.get().game_object_id << " Name: " << m.get().name - << " Tag: " << m.get().tag << " Parent: " << m.get().parent - << " Children: "; + << " Tag: " << m.get().tag << " Parent: " << m.get().parent << " Children: "; for (auto & c : m.get().children) { cout << c << " "; } cout << endl; } for (auto & t : transform) { - cout << "Id: " << t.get().game_object_id << " Position: [" - << t.get().position.x << ", " << t.get().position.y << "]" << endl; + cout << "Id: " << t.get().game_object_id << " Position: [" << t.get().position.x + << ", " << t.get().position.y << "]" << endl; } return 0; diff --git a/src/example/particles.cpp b/src/example/particles.cpp index 6eab046..3bdf35f 100644 --- a/src/example/particles.cpp +++ b/src/example/particles.cpp @@ -17,8 +17,7 @@ int main(int argc, char * argv[]) { GameObject game_object(0, "", "", Vector2{0, 0}, 0, 0); Color color(0, 0, 0, 0); Sprite test_sprite = game_object.add_component<Sprite>( - make_shared<Texture>("../asset/texture/img.png"), color, - FlipSettings{true, true}); + make_shared<Texture>("../asset/texture/img.png"), color, FlipSettings{true, true}); game_object.add_component<ParticleEmitter>(ParticleEmitter::Data{ .position = {0, 0}, .max_particles = 100, diff --git a/src/example/proxy.cpp b/src/example/proxy.cpp index 0afff41..b69ea03 100644 --- a/src/example/proxy.cpp +++ b/src/example/proxy.cpp @@ -23,8 +23,7 @@ int main() { ValueBroker<int> broker{ [&real_value](const int & target) { - dbg_logf("set %s to %s", to_string(real_value).c_str(), - to_string(target).c_str()); + dbg_logf("set %s to %s", to_string(real_value).c_str(), to_string(target).c_str()); real_value = target; }, [&real_value]() -> const int & { diff --git a/src/example/rendering.cpp b/src/example/rendering.cpp index 827ad07..e0281f2 100644 --- a/src/example/rendering.cpp +++ b/src/example/rendering.cpp @@ -27,16 +27,14 @@ int main() { // Normal adding components { Color color(0, 0, 0, 0); - obj.add_component<Sprite>( - make_shared<Texture>("../asset/texture/img.png"), color, - FlipSettings{false, false}); + obj.add_component<Sprite>(make_shared<Texture>("../asset/texture/img.png"), color, + FlipSettings{false, false}); obj.add_component<Camera>(Color::get_red()); } { Color color(0, 0, 0, 0); - obj1.add_component<Sprite>( - make_shared<Texture>("../asset/texture/second.png"), color, - FlipSettings{true, true}); + obj1.add_component<Sprite>(make_shared<Texture>("../asset/texture/second.png"), color, + FlipSettings{true, true}); } /* diff --git a/src/example/scene_manager.cpp b/src/example/scene_manager.cpp index f46dc36..c48d5e3 100644 --- a/src/example/scene_manager.cpp +++ b/src/example/scene_manager.cpp @@ -40,7 +40,9 @@ int main() { scene_mgr.add_scene<ConcreteScene1>("scene1"); scene_mgr.add_scene<ConcreteScene2>("scene2"); - // There is no need to call set_next_scene() at the beginnen, because the first scene will be automatically set as the next scene + // There is no need to call set_next_scene() at the beginnen, because the first scene will be + // automatically set as the next scene + // Load scene1 (the first scene added) scene_mgr.load_next_scene(); diff --git a/src/example/script.cpp b/src/example/script.cpp index 9e8b147..5411b77 100644 --- a/src/example/script.cpp +++ b/src/example/script.cpp @@ -39,8 +39,7 @@ int main() { auto obj = GameObject(0, "name", "tag", Vector2{1.2, 3.4}, 0, 1); obj.add_component<BehaviorScript>().set_script<MyScript>(); - // Get ScriptSystem singleton instance (this would normally be done from the - // game loop) + // Get ScriptSystem singleton instance (this would normally be done from the game loop) ScriptSystem sys; // Update all scripts. This should result in MyScript::update being called sys.update(); |