summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorMenase Teshale <osome3717@gmail.com>2026-09-19 12:12:31 +0300
committerMenase Teshale <osome3717@gmail.com>2026-09-19 12:12:31 +0300
commitaf1e4f1d6c47498a590bd64428163a6b9dbca385 (patch)
tree374e9028e45bcf960c4daf2790024482a8e72410 /src/main.c
parent9dfdb7df2929fcfdf5f932b2e27499d3f0e5d412 (diff)
Started relativising sizing and positioning
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c14
1 files changed, 12 insertions, 2 deletions
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;
+}