From 825e6afae180df69d0610ec772358384f5b0e268 Mon Sep 17 00:00:00 2001 From: Layla Marchant Date: Sat, 7 Mar 2020 00:24:37 -0500 Subject: [PATCH] Modified the HUD's powerup display for color accessibility. --- src/colors.c | 10 +++++++- src/colors.h | 4 ++++ src/game.c | 66 +++++++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 70 insertions(+), 10 deletions(-) diff --git a/src/colors.c b/src/colors.c index 9ed5b31..9f47940 100644 --- a/src/colors.c +++ b/src/colors.c @@ -27,10 +27,14 @@ along with this program. If not, see . Uint32 red; Uint32 darkRed; Uint32 yellow; +Uint32 lightYellow; Uint32 darkYellow; Uint32 green; +Uint32 lightGreen; Uint32 darkGreen; Uint32 blue; +Uint32 lightBlue; +Uint32 lighterBlue; Uint32 darkBlue; Uint32 darkerBlue; Uint32 black; @@ -49,13 +53,17 @@ void colors_init() darkRed = SDL_MapRGB(screen->format, 0x66, 0x00, 0x00); yellow = SDL_MapRGB(screen->format, 0xff, 0xff, 0x00); + lightYellow = SDL_MapRGB(screen->format, 0xff, 0xff, 0x80); darkYellow = SDL_MapRGB(screen->format, 0x66, 0x66, 0x00); green = SDL_MapRGB(screen->format, 0x00, 0xff, 0x00); + lightGreen = SDL_MapRGB(screen->format, 0x80, 0xff, 0x80); darkGreen = SDL_MapRGB(screen->format, 0x00, 0x66, 0x00); blue = SDL_MapRGB(screen->format, 0x00, 0x00, 0xff); - darkBlue = SDL_MapRGB(screen->format, 0x00, 0x00, 0x99); + lightBlue = SDL_MapRGB(screen->format, 0x99, 0x99, 0xff); + lighterBlue = SDL_MapRGB(screen->format, 0xbb, 0xbb, 0xff); + darkBlue = SDL_MapRGB(screen->format, 0x00, 0x00, 0xcc); darkerBlue = SDL_MapRGB(screen->format, 0x00, 0x00, 0x44); black = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00); diff --git a/src/colors.h b/src/colors.h index 091fde3..8c3a842 100644 --- a/src/colors.h +++ b/src/colors.h @@ -28,10 +28,14 @@ along with this program. If not, see . extern Uint32 red; extern Uint32 darkRed; extern Uint32 yellow; +extern Uint32 lightYellow; extern Uint32 darkYellow; extern Uint32 green; +extern Uint32 lightGreen; extern Uint32 darkGreen; extern Uint32 blue; +extern Uint32 lightBlue; +extern Uint32 lighterBlue; extern Uint32 darkBlue; extern Uint32 darkerBlue; extern Uint32 black; diff --git a/src/game.c b/src/game.c index 9a6e782..a7c6e7a 100644 --- a/src/game.c +++ b/src/game.c @@ -1874,6 +1874,8 @@ static void game_doHud() static int last_arrow = -1; int shieldColor = 0; SDL_Rect bar; + SDL_Rect bar_foutline; + SDL_Rect bar_fcolor; int fontColor; int tTextIndex; char text[STRMAX_SHORT]; @@ -2128,16 +2130,31 @@ static void game_doHud() bar.x = screen->w / 32 + gfx_textSprites[TS_POWER].image->w + 10; bar.y = screen->h - 29; + bar_foutline.x = bar.x + 2; + bar_foutline.y = bar.y + 2; + bar_foutline.w = bar.w - 4; + bar_foutline.h = bar.h - 4; + + bar_fcolor.x = bar_foutline.x + 2; + bar_fcolor.y = bar_foutline.y + 2; + bar_fcolor.w = bar_foutline.w - 4; + bar_fcolor.h = bar_foutline.h - 4; + for (int i = 1 ; i <= 5 ; i++) { if (weapons[W_PLAYER_WEAPON].damage >= i) { if(i <= game.maxPlasmaDamage || (SDL_GetTicks() % 1000 > (unsigned)i * 100)) { - SDL_FillRect(screen, &bar, green); + SDL_FillRect(screen, &bar, darkGreen); + SDL_FillRect(screen, &bar_foutline, green); + SDL_FillRect(screen, &bar_fcolor, lightGreen); } } else if (i <= game.maxPlasmaDamage) SDL_FillRect(screen, &bar, darkGreen); + bar.x += screen->w * 3 / 80; + bar_foutline.x = bar.x + 2; + bar_fcolor.x = bar_foutline.x + 2; } screen_blitText(TS_OUTPUT, screen->w * 5 / 16, screen->h - 30); @@ -2146,19 +2163,34 @@ static void game_doHud() bar.h = 12; bar.x = screen->w * 5 / 16 + gfx_textSprites[TS_OUTPUT].image->w + 10; bar.y = screen->h - 29; - SDL_FillRect(screen, &bar, yellow); + + bar_foutline.x = bar.x + 2; + bar_foutline.y = bar.y + 2; + bar_foutline.w = bar.w - 4; + bar_foutline.h = bar.h - 4; + + bar_fcolor.x = bar_foutline.x + 2; + bar_fcolor.y = bar_foutline.y + 2; + bar_fcolor.w = bar_foutline.w - 4; + bar_fcolor.h = bar_foutline.h - 4; for (int i = 1 ; i <= 5 ; i++) { - if (weapons[W_PLAYER_WEAPON].ammo[0] >= i) { - if(i <= game.maxPlasmaOutput || (SDL_GetTicks() % 1000 > (unsigned)i * 100)) + if (weapons[W_PLAYER_WEAPON].ammo[0] >= i) + { + if (i <= game.maxPlasmaOutput || (SDL_GetTicks() % 1000 > (unsigned)i * 100)) { - SDL_FillRect(screen, &bar, yellow); + SDL_FillRect(screen, &bar, darkYellow); + SDL_FillRect(screen, &bar_foutline, yellow); + SDL_FillRect(screen, &bar_fcolor, lightYellow); } } else if (i <= game.maxPlasmaOutput) SDL_FillRect(screen, &bar, darkYellow); + bar.x += screen->w * 3 / 80; + bar_foutline.x = bar.x + 2; + bar_fcolor.x = bar_foutline.x + 2; } screen_blitText(TS_COOLER, screen->w * 97 / 160, screen->h - 30); @@ -2168,17 +2200,33 @@ static void game_doHud() bar.x = screen->w * 97 / 160 + gfx_textSprites[TS_COOLER].image->w + 10; bar.y = screen->h - 29; + bar_foutline.x = bar.x + 2; + bar_foutline.y = bar.y + 2; + bar_foutline.w = bar.w - 4; + bar_foutline.h = bar.h - 4; + + bar_fcolor.x = bar_foutline.x + 2; + bar_fcolor.y = bar_foutline.y + 2; + bar_fcolor.w = bar_foutline.w - 4; + bar_fcolor.h = bar_foutline.h - 4; + for (int i = 1 ; i <= 5 ; i++) { - if (weapons[W_PLAYER_WEAPON].reload[0] <= rate2reload[i]) { - if(i <= game.maxPlasmaRate || (SDL_GetTicks() % 1000 > (unsigned)i * 100)) + if (weapons[W_PLAYER_WEAPON].reload[0] <= rate2reload[i]) + { + if (i <= game.maxPlasmaRate || (SDL_GetTicks() % 1000 > (unsigned)i * 100)) { - SDL_FillRect(screen, &bar, blue); + SDL_FillRect(screen, &bar, darkBlue); + SDL_FillRect(screen, &bar_foutline, lightBlue); + SDL_FillRect(screen, &bar_fcolor, lighterBlue); } } else if (i <= game.maxPlasmaRate) - SDL_FillRect(screen, &bar, darkerBlue); + SDL_FillRect(screen, &bar, darkBlue); + bar.x += screen->w * 3 / 80; + bar_foutline.x = bar.x + 2; + bar_fcolor.x = bar_foutline.x + 2; } screen_blitText(TS_SHIELD, screen->w / 32, screen->h - 50);