implemented some of the camera functions
This commit is contained in:
parent
5516a70d57
commit
ab38444790
20
src/camera.c
Normal file
20
src/camera.c
Normal 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
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue