From e5e358a33f517f6c6565fdef76bc0cd8ea3f6b35 Mon Sep 17 00:00:00 2001 From: Ulysse Cura Date: Sat, 28 Nov 2026 11:31:47 +0100 Subject: [PATCH] Added display scale per platform and camera mode. --- core/camera.c | 10 ++++++---- core/camera.h | 7 +++++++ core/host/fxcg50/display.h | 1 + core/host/linux/display.h | 1 + 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/core/camera.c b/core/camera.c index 2b6ccc5..8e64ffb 100644 --- a/core/camera.c +++ b/core/camera.c @@ -8,8 +8,8 @@ void camera_init(void) game.camera.view_rect = (rect_t) { .x = 0, .y = 0, - .w = DISPLAY_WIDTH / 2, - .h = DISPLAY_HEIGHT / 2 + .w = DISPLAY_WIDTH / DISPLAY_SCALE, + .h = DISPLAY_HEIGHT / DISPLAY_SCALE }; game.camera.tracking_pos = NULL; @@ -17,17 +17,19 @@ void camera_init(void) .x = 0, .y = 0 }; + + game.camera.mode = CAMERA_TRACKING; } void camera_update(void) { - if(game.camera.tracking_pos) + if(game.camera.mode & CAMERA_TRACKING) { game.camera.view_rect.x = (int)game.camera.tracking_pos->x + game.camera.tracking_center_offset.x - game.camera.view_rect.w / 2; game.camera.view_rect.y = (int)game.camera.tracking_pos->y + game.camera.tracking_center_offset.y - game.camera.view_rect.h / 2; } - if(game.map) + if(game.camera.mode & CAMERA_BOUND_MAP) { if(game.camera.view_rect.w > game.map->width * TILE_SIZE) { diff --git a/core/camera.h b/core/camera.h index fbbe7e9..f7a826d 100644 --- a/core/camera.h +++ b/core/camera.h @@ -3,10 +3,17 @@ #include "vector2d.h" +typedef enum camera_mode_t { + CAMERA_STATIC = 0x0000, + CAMERA_TRACKING = 0x0001, + CAMERA_BOUND_MAP = 0x0010, +} camera_mode_t; + typedef struct camera_t { rect_t view_rect; fvector2d_t *tracking_pos; vector2d_t tracking_center_offset; + camera_mode_t mode; } camera_t; void camera_init(void); diff --git a/core/host/fxcg50/display.h b/core/host/fxcg50/display.h index 2100124..4b6204e 100644 --- a/core/host/fxcg50/display.h +++ b/core/host/fxcg50/display.h @@ -13,6 +13,7 @@ #define DISPLAY_WIDTH DWIDTH #define DISPLAY_HEIGHT DHEIGHT +#define DISPLAY_SCALE 1 typedef int display_t; diff --git a/core/host/linux/display.h b/core/host/linux/display.h index c009bca..f4e9509 100644 --- a/core/host/linux/display.h +++ b/core/host/linux/display.h @@ -13,6 +13,7 @@ #define DISPLAY_WIDTH 720 #define DISPLAY_HEIGHT 480 +#define DISPLAY_SCALE 2 typedef struct display_t { SDL_Window *window;