From af1e4f1d6c47498a590bd64428163a6b9dbca385 Mon Sep 17 00:00:00 2001 From: Menase Teshale Date: Sat, 19 Sep 2026 12:12:31 +0300 Subject: Started relativising sizing and positioning --- src/main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index f1518fd..a1087ec 100644 --- a/src/main.c +++ b/src/main.c @@ -9,8 +9,8 @@ #include "app.h" #include "font.h" -#define WINDOW_WIDTH 800 -#define WINDOW_HEIGHT 600 +#define WINDOW_WIDTH 1280 +#define WINDOW_HEIGHT 720 #define WINDOW_TITLE "Match 3" #define MAX_DELTATIME (1000.0 / 30) @@ -21,6 +21,8 @@ MIX_Mixer* mixer; application_state app_state; +int window_width, window_height; + SDL_AppResult SDL_AppInit(void** userdata, int nargs, char** argc) { SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO); srand(time(NULL)); @@ -63,6 +65,7 @@ SDL_AppResult SDL_AppEvent(void* userdata, SDL_Event* e) { SDL_AppResult SDL_AppIterate(void* userdata) { static uint64_t then = 0, now = 0; + SDL_GetWindowSizeInPixels(window, &window_width, &window_height); then = now; now = SDL_GetTicks(); @@ -106,3 +109,10 @@ void init_app(SDL_Renderer* renderer, MIX_Mixer* mixer) { void free_app() { free_game(); } + +float get_window_relative_xpos(float vp) { + return vp * window_width; +} +float get_window_relative_ypos(float vp) { + return vp * window_height; +} -- cgit v1.2.3