From 4f0286525621030a1f88351ab8c3e46013c78c2d Mon Sep 17 00:00:00 2001 From: onpon4 Date: Sun, 3 Jan 2016 20:41:48 -0500 Subject: [PATCH] Added SCREEN_W and SCREEN_H definitions. These are just there so that you can define these at compile time without modifying the source code. In the future, I would like this to only be the *default* screen width and height, because I'll want to add an option in the menu to change the resolution from 640x480 up to whatever your monitor's resolution is. --- src/defs.h | 12 ++++++++++-- src/player.cpp | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/defs.h b/src/defs.h index 1de05da..3ac20d2 100644 --- a/src/defs.h +++ b/src/defs.h @@ -43,6 +43,14 @@ along with this program. If not, see . #define DATADIR "." #endif +#ifndef SCREEN_W +#define SCREEN_W 800 +#endif + +#ifndef SCREEN_H +#define SCREEN_H 600 +#endif + #ifndef PATH_MAX #define PATH_MAX 4096 #endif @@ -459,8 +467,8 @@ const char * const systemBackground[] = { }; const int rate2reload[6] = {15, 15, 13, 11, 9, 7}; -const int screenWidth = 800; -const int screenHeight = 600; +const int screenWidth = SCREEN_W; +const int screenHeight = SCREEN_H; const int xViewBorder = 100; const int yViewBorder = 100; const float cameraMaxSpeed = 3.; diff --git a/src/player.cpp b/src/player.cpp index adb4438..a7d5543 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -273,8 +273,8 @@ void getPlayerInput() int x, y, w, h; SDL_GetMouseState(&x, &y); SDL_GetWindowSize(window, &w, &h); - x = screenWidth * x / w; - y = screenHeight * y / h; + x = screen->w * x / w; + y = screen->h * y / h; if (px == x && py == y) { if(engine.keyState[KEY_UP] && engine.cursor_y > 0) engine.cursor_y -= 4;