Show current score in top-right corner of HUD
Some checks failed
Deploy / deploy (push) Failing after 58s

Display the player's current score using the font renderer,
right-aligned with an 8px margin from the top-right screen edge.

Closes #5

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit was merged in pull request #10.
This commit is contained in:
2026-03-14 20:09:05 +00:00
committed by tas
parent 81ebbd9eec
commit 79e9d0e2ad

View File

@@ -17,6 +17,7 @@
#include "engine/input.h"
#include "engine/camera.h"
#include "engine/assets.h"
#include "engine/font.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
@@ -779,6 +780,20 @@ void level_render(Level *level, float interpolation) {
}
}
/* Draw score in top-right corner */
{
GameStats *stats = stats_get_active();
if (stats) {
stats_update_score(stats);
char score_buf[16];
snprintf(score_buf, sizeof(score_buf), "%d", stats->score);
int text_w = font_text_width(score_buf);
font_draw_text(g_engine.renderer, score_buf,
SCREEN_WIDTH - text_w - 8, 8,
(SDL_Color){255, 220, 80, 255});
}
}
/* Flush the renderer */
renderer_flush(cam);
}