diff --git a/desktop_version/src/Constants.h b/desktop_version/src/Constants.h new file mode 100644 index 00000000..3d5aa8d7 --- /dev/null +++ b/desktop_version/src/Constants.h @@ -0,0 +1,18 @@ +#ifndef CONSTANTS_H +#define CONSTANTS_H + +/* + * FIXME: These should be used everywhere... + * FIXME: This should include more constants! + */ + +#define SCREEN_WIDTH_TILES 40 +#define SCREEN_HEIGHT_TILES 30 + +#define SCREEN_WIDTH_PIXELS (SCREEN_WIDTH_TILES * 8) +#define SCREEN_HEIGHT_PIXELS (SCREEN_WIDTH_TILES * 8) + +/* 4 bytes per char, for UTF-8 encoding. */ +#define SCREEN_WIDTH_CHARS (SCREEN_WIDTH_TILES * 4) + +#endif /* CONSTANTS_H */ diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 64809cbd..75b31dc1 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -6,6 +6,7 @@ #include #include +#include "Constants.h" #include "CustomLevels.h" #include "DeferCallbacks.h" #include "Editor.h" @@ -658,7 +659,7 @@ void Game::remaining_textbox(void) { const int remaining = 6 - crewrescued(); const char* string; - char buffer[161]; /* 4 bytes per 40 chars (whole screen) plus 1 for null terminator */ + char buffer[SCREEN_WIDTH_CHARS + 1]; if (remaining == 1) { string = " One remains "; diff --git a/desktop_version/src/Render.cpp b/desktop_version/src/Render.cpp index 2c8fa518..32a7737f 100644 --- a/desktop_version/src/Render.cpp +++ b/desktop_version/src/Render.cpp @@ -1,5 +1,6 @@ #include +#include "Constants.h" #include "Credits.h" #include "CustomLevels.h" #include "Editor.h" @@ -113,8 +114,7 @@ static void inline drawglitchrunnertext(void) int tempg = tg; int tempb = tb; - /* Screen width 40 chars, 4 per char */ - char buffer[160 + 1]; + char buffer[SCREEN_WIDTH_CHARS + 1]; const char* mode_string; @@ -406,8 +406,7 @@ static void menurender(void) break; } { - /* Screen width 40 chars, 4 per char */ - char buffer[160 + 1]; + char buffer[SCREEN_WIDTH_CHARS + 1]; char soundtrack[6 + 1]; char letter; if (music.usingmmmmmm) @@ -628,8 +627,7 @@ static void menurender(void) break; case 2: { - /* Screen width 40 chars, 4 per char */ - char buffer[160 + 1]; + char buffer[SCREEN_WIDTH_CHARS + 1]; const char* button; graphics.bigprint(-1, 30, "Interact Button", tr, tg, tb, true); @@ -1793,8 +1791,7 @@ void gamerender(void) if (game.readytotele > 100 || game.oldreadytotele > 100) { - /* Screen width 40 chars, 4 per char */ - char buffer[160 + 1]; + char buffer[SCREEN_WIDTH_CHARS + 1]; static const char raw[] = "- Press %s to Teleport - "; const char* final_string = interact_prompt( buffer, @@ -1990,8 +1987,7 @@ void gamerender(void) float act_alpha = graphics.lerp(game.prev_act_fade, game.act_fade) / 10.0f; if(game.act_fade>5 || game.prev_act_fade>5) { - /* Screen width 40 chars, 4 per char */ - char buffer[160 + 1]; + char buffer[SCREEN_WIDTH_CHARS + 1]; const char* final_string = interact_prompt( buffer, sizeof(buffer), @@ -2882,8 +2878,7 @@ void teleporterrender(void) if (game.useteleporter) { - /* Screen width 40 chars, 4 per char */ - char buffer[160 + 1]; + char buffer[SCREEN_WIDTH_CHARS + 1]; static const char raw[] = "Press %s to Teleport"; const char* final_string = interact_prompt( buffer,