Show current score in top-right corner #10
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user