diff --git a/coresdk/src/coresdk/camera.cpp b/coresdk/src/coresdk/camera.cpp index 0571939d..7a05f00d 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 a6512616..574d89be 100644 --- a/coresdk/src/coresdk/camera.h +++ b/coresdk/src/coresdk/camera.h @@ -89,6 +89,13 @@ namespace splashkit_lib */ point_2d screen_center(); + /** + * 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). + */ + void reset_camera(); + //--------------------------------------------------------------------------- // World-To-Screen Translation //--------------------------------------------------------------------------- diff --git a/coresdk/src/test/test_camera.cpp b/coresdk/src/test/test_camera.cpp index b788081a..c3e68368 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); @@ -69,5 +72,10 @@ void run_camera_test() refresh_screen(); } + reset_camera(); + + assert(camera_x() == 0); + assert(camera_y() == 0); + close_window(w1); }