diff options
| author | nathan <nathansmith@disroot.org> | 2026-01-07 07:28:35 +0000 |
|---|---|---|
| committer | nathan <nathansmith@disroot.org> | 2026-01-07 07:28:35 +0000 |
| commit | 0fb94d28d3f64e95ff228edbfd8fc17d420e215f (patch) | |
| tree | 5a8103ad392cbb3df9b419a941f66050d1892f2b /src/game.c | |
| parent | e27d509615ca48c8b007f66349f554ce2a9758f9 (diff) | |
| download | FindThings-0fb94d28d3f64e95ff228edbfd8fc17d420e215f.tar.gz FindThings-0fb94d28d3f64e95ff228edbfd8fc17d420e215f.tar.bz2 FindThings-0fb94d28d3f64e95ff228edbfd8fc17d420e215f.zip | |
Status bar thingy going well
Diffstat (limited to 'src/game.c')
| -rw-r--r-- | src/game.c | 41 |
1 files changed, 37 insertions, 4 deletions
@@ -197,7 +197,7 @@ void updateGameEntityInfo(Game* game) } Color backgroundColor = PINK; - backgroundColor.a = game->settings.entityInfoAlpha; + backgroundColor.a = game->settings.statusAndInfoAlpha; DrawRectangle(x, y, screenWidth - x, lines * fontSize, backgroundColor); // Draw name. @@ -205,9 +205,42 @@ void updateGameEntityInfo(Game* game) DrawText(getEntityName(selectedEntity->id), x, y, fontSize, BLACK); } -void updateGameTopStatus(Game* game) +void updateGameStatus(Game* game) { - DrawText(TextFormat("Speed %.2f", game->player.speed), 150.0, 1.0, 20, GREEN); + float x; + float y; + float width; + float height; + int fontSize = 20; + int lineCount = 2; + int maxColumns = 16; + float maxWidth = maxColumns * fontSize / 2.0; + bool topBarStyle = game->screen.destination.x < maxWidth; + + const char* spacer = topBarStyle ? ", " : "\n"; + + const char* text = TextFormat( + "Speed %d kps%sPee level: 7", (int)roundf(game->player.speed), spacer); + + if (topBarStyle) // Top bar style. + { + x = 110.0; + y = 1.0; + width = (getStringLength(text, 255) + 1) * fontSize / 2.0; + height = fontSize; + } + else // Side bar style. + { + x = 1.0; + y = game->showFPS ? 20.0 : 0.0; + width = maxWidth; + height = fontSize * lineCount; + } + + Color backgroundColor = PINK; + backgroundColor.a = game->settings.statusAndInfoAlpha; + DrawRectangle(x, y, width, height, backgroundColor); + DrawText(text, x, y, fontSize, BLACK); } void updateGameScene(Game* game) @@ -272,7 +305,7 @@ void updateGameScene(Game* game) updateMap(&game->map, game); updateGameEntityInfo(game); - updateGameTopStatus(game); + updateGameStatus(game); updateInteractionChat(&game->interactionChat, game); updateInteractionMenu(&game->interactionMenu, game); } |
