From 4433cc6943649111b46347dffbc526569bd7bb78 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Thu, 1 Sep 2022 13:14:15 +0200 Subject: [PATCH] Invertido el separador del reloj --- source/scoreboard.cpp | 8 +++++++- source/scoreboard.h | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/source/scoreboard.cpp b/source/scoreboard.cpp index a2140e3..9a248b0 100644 --- a/source/scoreboard.cpp +++ b/source/scoreboard.cpp @@ -110,7 +110,12 @@ void ScoreBoard::render() // Escribe los textos const clock_t clock = getTime(); std::string itemsTxt = std::to_string(*items / 100) + std::to_string((*items % 100) / 10) + std::to_string(*items % 10); - std::string timeTxt = std::to_string((clock.minutes % 60) / 10) + std::to_string(clock.minutes % 10) + ":" + std::to_string((clock.seconds % 60) / 10) + std::to_string(clock.seconds % 10); + std::string separator = " "; + if (clock.separator) + { + separator = ":"; + } + std::string timeTxt = std::to_string((clock.minutes % 60) / 10) + std::to_string(clock.minutes % 10) + separator + std::to_string((clock.seconds % 60) / 10) + std::to_string(clock.seconds % 10); std::string text = "Items collected " + itemsTxt + " Time " + timeTxt; const color_t color = stringToColor("white"); this->text->writeColored(BLOCK, 21 * BLOCK, text, color); @@ -131,5 +136,6 @@ ScoreBoard::clock_t ScoreBoard::getTime() time.hours = timeElapsed / 3600000; time.minutes = timeElapsed / 60000; time.seconds = timeElapsed / 1000; + time.separator = (timeElapsed % 1000 <= 500); return time; } \ No newline at end of file diff --git a/source/scoreboard.h b/source/scoreboard.h index 227a271..83b3952 100644 --- a/source/scoreboard.h +++ b/source/scoreboard.h @@ -20,6 +20,7 @@ private: int hours; int minutes; int seconds; + bool separator; }; LTexture *texture; // Textura con los graficos para las vidas @@ -33,7 +34,6 @@ private: int *lives; // Número ara mostrar en el marcador de vidas int *items; // Número para mostrar en el marcador de items Uint32 *clock; // Contiene el tiempo de inicio de la partida - clock_t time; // Contiene el tiempo de partida transcurrido // Obtiene el tiempo transcurrido de partida clock_t getTime();