diff options
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -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; +} |
