From a549c4315d5bb283c99b0db46627453cff2031a2 Mon Sep 17 00:00:00 2001 From: olive_tree_branch Date: Sat, 15 Aug 2026 13:19:34 +1000 Subject: [PATCH 1/4] Added reset_camera function Added in a new function that will reset the camera to x:0, y:0 and avoid the user having to use set_x/y_camera functions to reset the position to (0,0) The function was added to the coresponding unit test and works with no new errors --- coresdk/src/coresdk/camera.cpp | 6 +++++- coresdk/src/coresdk/camera.h | 4 ++++ coresdk/src/test/test_camera.cpp | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/coresdk/src/coresdk/camera.cpp b/coresdk/src/coresdk/camera.cpp index 0571939d4..7a05f00d1 100644 --- a/coresdk/src/coresdk/camera.cpp +++ b/coresdk/src/coresdk/camera.cpp @@ -56,7 +56,11 @@ namespace splashkit_lib return point_at(_camera_x + screen_width() / 2.0f, _camera_y + screen_height() / 2.0f); } - + void reset_camera() + { + _camera_x = 0; + _camera_y = 0; + } //--------------------------------------------------------------------------- // World-To-Screen Translation diff --git a/coresdk/src/coresdk/camera.h b/coresdk/src/coresdk/camera.h index a65126163..84236ac45 100644 --- a/coresdk/src/coresdk/camera.h +++ b/coresdk/src/coresdk/camera.h @@ -89,6 +89,10 @@ namespace splashkit_lib */ point_2d screen_center(); + /** + * Set the camera back to the centre position on the screen + */ + void reset_camera(); //--------------------------------------------------------------------------- // World-To-Screen Translation //--------------------------------------------------------------------------- diff --git a/coresdk/src/test/test_camera.cpp b/coresdk/src/test/test_camera.cpp index b788081a9..5371fd5b6 100644 --- a/coresdk/src/test/test_camera.cpp +++ b/coresdk/src/test/test_camera.cpp @@ -69,5 +69,7 @@ void run_camera_test() refresh_screen(); } + reset_camera(); + close_window(w1); } From 94776c19265c1fa624177ef3e47912dbec6993b7 Mon Sep 17 00:00:00 2001 From: olive_tree_branch Date: Sat, 15 Aug 2026 16:27:37 +1000 Subject: [PATCH 2/4] Updated documentation Added what the equivilent of this function would be into the documentation --- coresdk/src/coresdk/camera.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/coresdk/src/coresdk/camera.h b/coresdk/src/coresdk/camera.h index 84236ac45..70a50b4ae 100644 --- a/coresdk/src/coresdk/camera.h +++ b/coresdk/src/coresdk/camera.h @@ -90,9 +90,12 @@ namespace splashkit_lib point_2d screen_center(); /** - * Set the camera back to the centre position on the screen + * Set the camera back to the centre position on the screen. + * + * This is the equivilent to calling the functions set_camera_x(0) and set_camera_y(0). */ void reset_camera(); + //--------------------------------------------------------------------------- // World-To-Screen Translation //--------------------------------------------------------------------------- From 1965081274be90872b0ff705317c7cdde49a9f2b Mon Sep 17 00:00:00 2001 From: olive_tree_branch Date: Tue, 18 Aug 2026 16:18:59 +1000 Subject: [PATCH 3/4] Added checks for camera position Included the `` header and added in checks that the camera was reseting to (0,0) everytime the test was complete --- coresdk/src/test/test_camera.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/coresdk/src/test/test_camera.cpp b/coresdk/src/test/test_camera.cpp index 5371fd5b6..c3e68368a 100644 --- a/coresdk/src/test/test_camera.cpp +++ b/coresdk/src/test/test_camera.cpp @@ -6,6 +6,7 @@ // Copyright © 2016 Andrew Cain. All rights reserved. // +#include #include "window_manager.h" #include "sprites.h" #include "graphics.h" @@ -52,8 +53,10 @@ void run_camera_test() } else { - set_camera_x(0); - set_camera_y(0); + reset_camera(); + + assert(camera_x() == 0); + assert(camera_y() == 0); } clear_screen(COLOR_WHITE); @@ -71,5 +74,8 @@ void run_camera_test() reset_camera(); + assert(camera_x() == 0); + assert(camera_y() == 0); + close_window(w1); } From 2365763efefac9627680da15a829920f85a3a9d5 Mon Sep 17 00:00:00 2001 From: Michael N <59274326+olive-tree-branch@users.noreply.github.com> Date: Wed, 19 Aug 2026 02:14:54 +0000 Subject: [PATCH 4/4] Changed documentation Changed the wording in the header documentation to be more clear what the outcome is --- coresdk/src/coresdk/camera.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coresdk/src/coresdk/camera.h b/coresdk/src/coresdk/camera.h index 70a50b4ae..574d89be5 100644 --- a/coresdk/src/coresdk/camera.h +++ b/coresdk/src/coresdk/camera.h @@ -90,7 +90,7 @@ namespace splashkit_lib point_2d screen_center(); /** - * Set the camera back to the centre position on the screen. + * Reset the camera position back to (x = 0, y = 0). * * This is the equivilent to calling the functions set_camera_x(0) and set_camera_y(0). */