diff --git a/src/camera.c b/src/camera.c new file mode 100644 index 0000000..3c3089b --- /dev/null +++ b/src/camera.c @@ -0,0 +1,20 @@ +#include "camera.h" +#include "render.h" + +Camera g_camera; + +void camera_init() { + g_camera.centre = ZeroVector; + g_camera.width = 1; +} + +SDL_FRect render_calculate_unit_rect() { + // If the camera's width is 1, this rectangle should fill the width of the screen. + // If the camera's width is 2, this rectangle should fill half the width of the screen. + return (SDL_FRect) { + .x = -g_camera.centre.x * g_render_resolution.x, + .y = -g_camera.centre.y * g_render_resolution.x, + .w = g_render_resolution.x / g_camera.width, + .h = g_render_resolution.x / g_camera.width + }; +}