aboutsummaryrefslogtreecommitdiff
path: root/src/example/components_internal.cpp
diff options
context:
space:
mode:
authorheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 14:08:36 +0100
committerheavydemon21 <nielsstunnebrink1@gmail.com>2024-11-18 14:08:36 +0100
commit20fc8401083e23e414feae2a9a4d217b228b8f15 (patch)
tree08c9e9c4ddcde5438eb54f6b051895c0896f935b /src/example/components_internal.cpp
parent60669b60e63532bc264ecd6d106bd15f0688a5b6 (diff)
parent121b64b1cb6cfead5814070c8b0185d3d7308095 (diff)
Merge remote-tracking branch 'origin/master' into niels/rendering_color
Diffstat (limited to 'src/example/components_internal.cpp')
-rw-r--r--src/example/components_internal.cpp23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/example/components_internal.cpp b/src/example/components_internal.cpp
index ea1eaad..2a232a9 100644
--- a/src/example/components_internal.cpp
+++ b/src/example/components_internal.cpp
@@ -13,7 +13,7 @@
#include <crepe/api/Rigidbody.h>
#include <crepe/api/Sprite.h>
-#include <crepe/util/log.h>
+#include <crepe/util/Log.h>
using namespace crepe;
using namespace std;
@@ -23,17 +23,14 @@ 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,14 +42,8 @@ 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
- - 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());