From aa9d673aabbaa525c8cbcc0714fef606ef853c8e Mon Sep 17 00:00:00 2001 From: Julie Marchant Date: Mon, 20 May 2019 11:25:05 -0400 Subject: [PATCH] Changed screenWidth and screenHeight to #defines. --- configure.ac | 6 ++++++ src/defs.h | 20 ++++++++++---------- src/engine.cpp | 4 ++-- src/intermission.h | 2 +- src/shop.cpp | 2 +- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/configure.ac b/configure.ac index 466dc64..c2e415e 100644 --- a/configure.ac +++ b/configure.ac @@ -33,9 +33,15 @@ AC_ARG_VAR([SF_SCREEN_WIDTH], [The width of the game window in pixels]) AC_ARG_VAR([SF_SCREEN_HEIGHT], [The height of the game window in pixels]) AS_IF([test -n "$SF_SCREEN_WIDTH"], [ STARFIGHTER_CFLAGS="$STARFIGHTER_CFLAGS -DSCREEN_WIDTH=$SF_SCREEN_WIDTH" + echo "Using default screen width of $SF_SCREEN_WIDTH" +], [ + echo "Using built-in screen width default" ]) AS_IF([test -n "$SF_SCREEN_HEIGHT"], [ STARFIGHTER_CFLAGS="$STARFIGHTER_CFLAGS -DSCREEN_HEIGHT=$SF_SCREEN_HEIGHT" + echo "Using default screen height of $SF_SCREEN_HEIGHT" +], [ + echo "Using built-in screen height default" ]) AC_SUBST([STARFIGHTER_CFLAGS]) diff --git a/src/defs.h b/src/defs.h index 6e9e891..d634689 100644 --- a/src/defs.h +++ b/src/defs.h @@ -59,7 +59,17 @@ along with this program. If not, see . #define FULLSCREEN SDL_WINDOW_FULLSCREEN +#define DEFAULT_SCREEN_WIDTH MAX(SCREEN_WIDTH, 640) +#define DEFAULT_SCREEN_HEIGHT MAX(SCREEN_HEIGHT, 480) #define STARS_NUM 200 +const int xViewBorder = 100; +const int yViewBorder = 100; +const float cameraMaxSpeed = 3.; +const int maxHoming = 20; +const int maxDoubleHoming = 15; +const int maxMicroHoming = 10; + +const int rayDamageDelay = 10; // Object Flags #define FL_WEAPCO 1 @@ -755,15 +765,5 @@ const char * const systemBackground[] = { }; const int rate2reload[6] = {15, 15, 13, 11, 9, 7}; -const int screenWidth = MAX(SCREEN_WIDTH, 640); -const int screenHeight = MAX(SCREEN_HEIGHT, 480); -const int xViewBorder = 100; -const int yViewBorder = 100; -const float cameraMaxSpeed = 3.; -const int maxHoming = 20; -const int maxDoubleHoming = 15; -const int maxMicroHoming = 10; - -const int rayDamageDelay = 10; #endif diff --git a/src/engine.cpp b/src/engine.cpp index 677bced..bca2cf1 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -267,11 +267,11 @@ void engine_setMode() engine.useMusic = useMusic; engine.autoPause = autoPause; - screen = SDL_CreateRGBSurface(0, screenWidth, screenHeight, 32, 0xff0000, 0xff00, 0xff, 0xff000000); + screen = SDL_CreateRGBSurface(0, DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, 32, 0xff0000, 0xff00, 0xff, 0xff000000); if (!screen) { - printf("Couldn't create %ix%ix32 surface: %s\n", screenWidth, screenHeight, SDL_GetError()); + printf("Couldn't create %ix%ix32 surface: %s\n", DEFAULT_SCREEN_WIDTH, DEFAULT_SCREEN_HEIGHT, SDL_GetError()); exit(1); } diff --git a/src/intermission.h b/src/intermission.h index 6ec1846..f08571d 100644 --- a/src/intermission.h +++ b/src/intermission.h @@ -25,7 +25,7 @@ along with this program. If not, see . extern Planet intermission_planets[MAX_PLANETS]; -const int intermission_ycenter = 50 + (screenHeight - 150) / 2; +const int intermission_ycenter = 50 + (DEFAULT_SCREEN_HEIGHT - 150) / 2; void intermission_initPlanets(int system); void intermission_unlockPlanets(); diff --git a/src/shop.cpp b/src/shop.cpp index bbf682b..1e1af8d 100644 --- a/src/shop.cpp +++ b/src/shop.cpp @@ -44,7 +44,7 @@ typedef struct ShopItem_ { } ShopItem; static const int shop_w = 600; -static const int shop_x = screenWidth / 2 - shop_w / 2; +static const int shop_x = DEFAULT_SCREEN_WIDTH / 2 - shop_w / 2; static const int shop_h = 336; static const int shop_y = intermission_ycenter - shop_h / 2;