From dc7a1c3d669b901adb9c520b4a76a868a3cc94e9 Mon Sep 17 00:00:00 2001 From: heavydemon21 Date: Sun, 8 Dec 2024 12:54:35 +0100 Subject: fixed inputtest test because of adjusting inputtest values. however inputtest passes while sdlcontext returns pixel coordinates????? --- src/crepe/facade/SDLContext.cpp | 4 ++++ src/test/CMakeLists.txt | 2 +- src/test/InputTest.cpp | 16 ++++++++-------- src/test/Profiling.cpp | 16 +++++++--------- 4 files changed, 20 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index 4cc2206..e010ac3 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -324,6 +325,8 @@ SDLContext::CameraValues SDLContext::set_camera(const Camera & cam) { render_scale.x = render_scale.y = scale; } + //cout << render_scale.x << " " << bar_size.x << " " << bar_size.y << endl; + SDL_SetRenderDrawColor(this->game_renderer.get(), cam_data.bg_color.r, cam_data.bg_color.g, cam_data.bg_color.b, cam_data.bg_color.a); @@ -374,6 +377,7 @@ ivec2 SDLContext::get_size(const Texture & ctx) { void SDLContext::delay(int ms) const { SDL_Delay(ms); } + std::vector SDLContext::get_events() { std::vector event_list; SDL_Event event; diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index c9cbac5..eae59f2 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -13,8 +13,8 @@ target_sources(test_main PUBLIC ValueBrokerTest.cpp DBTest.cpp Vector2Test.cpp + Profiling.cpp InputTest.cpp ScriptEventTest.cpp ScriptSceneTest.cpp - Profiling.cpp ) diff --git a/src/test/InputTest.cpp b/src/test/InputTest.cpp index a7c0157..73eaab3 100644 --- a/src/test/InputTest.cpp +++ b/src/test/InputTest.cpp @@ -61,7 +61,7 @@ protected: TEST_F(InputTest, MouseDown) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; bool mouse_triggered = false; EventHandler on_mouse_down = [&](const MousePressEvent & event) { @@ -91,7 +91,7 @@ TEST_F(InputTest, MouseDown) { TEST_F(InputTest, MouseUp) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; bool function_triggered = false; EventHandler on_mouse_release = [&](const MouseReleaseEvent & e) { @@ -119,7 +119,7 @@ TEST_F(InputTest, MouseUp) { TEST_F(InputTest, MouseMove) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; bool function_triggered = false; EventHandler on_mouse_move = [&](const MouseMoveEvent & e) { @@ -149,7 +149,7 @@ TEST_F(InputTest, MouseMove) { TEST_F(InputTest, KeyDown) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; bool function_triggered = false; @@ -180,7 +180,7 @@ TEST_F(InputTest, KeyDown) { TEST_F(InputTest, KeyUp) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; bool function_triggered = false; EventHandler on_key_release = [&](const KeyReleaseEvent & event) { @@ -204,7 +204,7 @@ TEST_F(InputTest, KeyUp) { TEST_F(InputTest, MouseClick) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; bool on_click_triggered = false; EventHandler on_mouse_click = [&](const MouseClickEvent & event) { @@ -225,7 +225,7 @@ TEST_F(InputTest, MouseClick) { TEST_F(InputTest, testButtonClick) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; GameObject button_obj = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); bool button_clicked = false; @@ -252,7 +252,7 @@ TEST_F(InputTest, testButtonClick) { TEST_F(InputTest, testButtonHover) { GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1); auto & camera = obj.add_component( - ivec2{100, 100}, vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); + ivec2{0, 0}, vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f}); camera.active = true; GameObject button_obj = mgr.new_object("body", "person", vec2{0, 0}, 0, 1); bool button_clicked = false; diff --git a/src/test/Profiling.cpp b/src/test/Profiling.cpp index c753bca..d40ee1d 100644 --- a/src/test/Profiling.cpp +++ b/src/test/Profiling.cpp @@ -1,7 +1,3 @@ -#include "manager/Mediator.h" -#include "system/ParticleSystem.h" -#include "system/PhysicsSystem.h" -#include "system/RenderSystem.h" #include #include #include @@ -21,6 +17,10 @@ #include #include #include +#include "manager/Mediator.h" +#include "system/ParticleSystem.h" +#include "system/PhysicsSystem.h" +#include "system/RenderSystem.h" using namespace std; using namespace std::chrono_literals; @@ -47,7 +47,7 @@ public: // Minimum amount to let test pass const int min_gameobject_count = 100; // Maximum amount to stop test - const int max_gameobject_count = 150; + const int max_gameobject_count = 1000; // Amount of times a test runs to calculate average const int average = 5; // Maximum duration to stop test @@ -98,10 +98,8 @@ public: std::chrono::microseconds run_all_systems() { std::chrono::microseconds total_microseconds = 0us; total_microseconds += time_function("PhysicsSystem", [&]() { physics_sys.update(); }); - total_microseconds - += time_function("CollisionSystem", [&]() { collision_sys.update(); }); - total_microseconds - += time_function("ParticleSystem", [&]() { particle_sys.update(); }); + //total_microseconds += time_function("CollisionSystem", [&]() { collision_sys.update(); }); + total_microseconds += time_function("ParticleSystem", [&]() { particle_sys.update(); }); total_microseconds += time_function("RenderSystem", [&]() { render_sys.update(); }); return total_microseconds; } -- cgit v1.2.3 From d3753404cdf58e529865782e7e3679aadb5bc18f Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Mon, 9 Dec 2024 09:07:58 +0100 Subject: revert #66 except for `src/test/InputTest.cpp` --- src/crepe/facade/SDLContext.cpp | 4 ---- src/test/CMakeLists.txt | 2 +- src/test/Profiling.cpp | 16 +++++++++------- 3 files changed, 10 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp index e010ac3..4cc2206 100644 --- a/src/crepe/facade/SDLContext.cpp +++ b/src/crepe/facade/SDLContext.cpp @@ -11,7 +11,6 @@ #include #include #include -#include #include #include @@ -325,8 +324,6 @@ SDLContext::CameraValues SDLContext::set_camera(const Camera & cam) { render_scale.x = render_scale.y = scale; } - //cout << render_scale.x << " " << bar_size.x << " " << bar_size.y << endl; - SDL_SetRenderDrawColor(this->game_renderer.get(), cam_data.bg_color.r, cam_data.bg_color.g, cam_data.bg_color.b, cam_data.bg_color.a); @@ -377,7 +374,6 @@ ivec2 SDLContext::get_size(const Texture & ctx) { void SDLContext::delay(int ms) const { SDL_Delay(ms); } - std::vector SDLContext::get_events() { std::vector event_list; SDL_Event event; diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index eae59f2..c9cbac5 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -13,8 +13,8 @@ target_sources(test_main PUBLIC ValueBrokerTest.cpp DBTest.cpp Vector2Test.cpp - Profiling.cpp InputTest.cpp ScriptEventTest.cpp ScriptSceneTest.cpp + Profiling.cpp ) diff --git a/src/test/Profiling.cpp b/src/test/Profiling.cpp index d40ee1d..c753bca 100644 --- a/src/test/Profiling.cpp +++ b/src/test/Profiling.cpp @@ -1,3 +1,7 @@ +#include "manager/Mediator.h" +#include "system/ParticleSystem.h" +#include "system/PhysicsSystem.h" +#include "system/RenderSystem.h" #include #include #include @@ -17,10 +21,6 @@ #include #include #include -#include "manager/Mediator.h" -#include "system/ParticleSystem.h" -#include "system/PhysicsSystem.h" -#include "system/RenderSystem.h" using namespace std; using namespace std::chrono_literals; @@ -47,7 +47,7 @@ public: // Minimum amount to let test pass const int min_gameobject_count = 100; // Maximum amount to stop test - const int max_gameobject_count = 1000; + const int max_gameobject_count = 150; // Amount of times a test runs to calculate average const int average = 5; // Maximum duration to stop test @@ -98,8 +98,10 @@ public: std::chrono::microseconds run_all_systems() { std::chrono::microseconds total_microseconds = 0us; total_microseconds += time_function("PhysicsSystem", [&]() { physics_sys.update(); }); - //total_microseconds += time_function("CollisionSystem", [&]() { collision_sys.update(); }); - total_microseconds += time_function("ParticleSystem", [&]() { particle_sys.update(); }); + total_microseconds + += time_function("CollisionSystem", [&]() { collision_sys.update(); }); + total_microseconds + += time_function("ParticleSystem", [&]() { particle_sys.update(); }); total_microseconds += time_function("RenderSystem", [&]() { render_sys.update(); }); return total_microseconds; } -- cgit v1.2.3