implemented some of the camera functions

This commit is contained in:
Sara 2023-09-23 22:53:07 +02:00
parent 5516a70d57
commit ab38444790

20
src/camera.c Normal file
View file

@ -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
};
}