diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-13 13:10:25 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-13 13:10:25 +0100 |
commit | fac06d488e635583307cd4a916a611500fb64c16 (patch) | |
tree | f62f79cc8ba540498d5dfa1deb4379469738a682 /src/example/components_internal.cpp | |
parent | 9d58e897fb68ab8dd001a5085cde2fae4634c274 (diff) |
cleanup + fix examples
Diffstat (limited to 'src/example/components_internal.cpp')
-rw-r--r-- | src/example/components_internal.cpp | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/example/components_internal.cpp b/src/example/components_internal.cpp index ea1eaad..dd4c7df 100644 --- a/src/example/components_internal.cpp +++ b/src/example/components_internal.cpp @@ -23,17 +23,16 @@ using namespace std; int main() { dbg_trace(); - auto & mgr = ComponentManager::get_instance(); + ComponentManager mgr{}; auto start_adding = chrono::high_resolution_clock::now(); GameObject * game_object[OBJ_COUNT]; for (int i = 0; i < OBJ_COUNT; ++i) { - game_object[i] = new GameObject(i, "Name", "Tag", 0); - - game_object[i]->add_component<Sprite>("test"); - game_object[i]->add_component<Rigidbody>(0, 0, i); + GameObject & obj = mgr.new_object("Name", "Tag"); + obj.add_component<Sprite>("test"); + obj.add_component<Rigidbody>(0, 0, i); } auto stop_adding = chrono::high_resolution_clock::now(); @@ -45,10 +44,6 @@ int main() { auto stop_looping = chrono::high_resolution_clock::now(); - for (int i = 0; i < OBJ_COUNT; ++i) { - 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 |