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.
This commit is contained in:
onpon4 2016-01-03 20:41:48 -05:00
parent 05323ed1fb
commit 4f02865256
2 changed files with 12 additions and 4 deletions

View File

@ -43,6 +43,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DATADIR "." #define DATADIR "."
#endif #endif
#ifndef SCREEN_W
#define SCREEN_W 800
#endif
#ifndef SCREEN_H
#define SCREEN_H 600
#endif
#ifndef PATH_MAX #ifndef PATH_MAX
#define PATH_MAX 4096 #define PATH_MAX 4096
#endif #endif
@ -459,8 +467,8 @@ const char * const systemBackground[] = {
}; };
const int rate2reload[6] = {15, 15, 13, 11, 9, 7}; const int rate2reload[6] = {15, 15, 13, 11, 9, 7};
const int screenWidth = 800; const int screenWidth = SCREEN_W;
const int screenHeight = 600; const int screenHeight = SCREEN_H;
const int xViewBorder = 100; const int xViewBorder = 100;
const int yViewBorder = 100; const int yViewBorder = 100;
const float cameraMaxSpeed = 3.; const float cameraMaxSpeed = 3.;

View File

@ -273,8 +273,8 @@ void getPlayerInput()
int x, y, w, h; int x, y, w, h;
SDL_GetMouseState(&x, &y); SDL_GetMouseState(&x, &y);
SDL_GetWindowSize(window, &w, &h); SDL_GetWindowSize(window, &w, &h);
x = screenWidth * x / w; x = screen->w * x / w;
y = screenHeight * y / h; y = screen->h * y / h;
if (px == x && py == y) { if (px == x && py == y) {
if(engine.keyState[KEY_UP] && engine.cursor_y > 0) if(engine.keyState[KEY_UP] && engine.cursor_y > 0)
engine.cursor_y -= 4; engine.cursor_y -= 4;