Add a timer on the top-right

This commit is contained in:
Edgaru089 2024-04-30 15:57:40 +08:00
parent 6acb513619
commit e27ab237ba
2 changed files with 14 additions and 0 deletions

View File

@ -171,6 +171,7 @@ extern "C" void app_Render(App *app) {
settextcolor(RGB(255, 255, 255));
setbkcolor(RGB(0, 0, 0));
// If paused, display a text
if (app->paused)
@ -181,6 +182,18 @@ extern "C" void app_Render(App *app) {
render_DrawTextEx(buf, box2(SCREEN_WIDTH / 2.0 - 10, 50, 20, 100), DT_CENTER | DT_NOCLIP);
}
// Display a Timer
if (strcmp(app->current_level, "title.txt") != 0) {
char buf[64];
snprintf(
buf, sizeof(buf),
"%02d:%02d.%02d",
app->level_playtime.microseconds / 1000 / 1000 / 60,
app->level_playtime.microseconds / 1000 / 1000 % 60,
app->level_playtime.microseconds / 10000 % 100);
render_DrawTextEx(buf, box2(0, 0, SCREEN_WIDTH, TEXTHEIGHT), DT_RIGHT);
}
// Draw UI
ui_Render(app->ui);
}

View File

@ -63,6 +63,7 @@ int main() {
app_Render(app);
if (app->debugOn) {
setbkcolor(0);
app_DebugText(app, debugText);
render_DrawText(10, 10, (const char *)vector_Data(debugText));
}