diff options
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); } |
