From e27ab237ba92df3e75f3b4c09d4329f5316fb680 Mon Sep 17 00:00:00 2001 From: Edgaru089 Date: Tue, 30 Apr 2024 15:57:40 +0800 Subject: [PATCH] Add a timer on the top-right --- app_render.cpp | 13 +++++++++++++ main.cpp | 1 + 2 files changed, 14 insertions(+) diff --git a/app_render.cpp b/app_render.cpp index 5b436e7..80ba094 100644 --- a/app_render.cpp +++ b/app_render.cpp @@ -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); } diff --git a/main.cpp b/main.cpp index 0825e63..3c1d334 100644 --- a/main.cpp +++ b/main.cpp @@ -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)); }