From 149e4224890e9506b9978e833d7dfb0dd05544dc Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Mon, 26 Aug 2024 10:52:59 +0200 Subject: [PATCH] Ara es pot activar o desactivar el comptador de frames per segon amb una tecla --- source/common/screen.cpp | 16 +++++++++++++--- source/common/screen.h | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/source/common/screen.cpp b/source/common/screen.cpp index aac0aec..9276ac5 100644 --- a/source/common/screen.cpp +++ b/source/common/screen.cpp @@ -40,6 +40,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input * fpsTicks = 0; fpsCounter = 0; fps = 0; + showFps = false; // Crea los objetos notify = new Notify(renderer, asset->get("notify.png"), asset->get("8bithud.png"), asset->get("8bithud.txt"), asset->get("notify.wav"), options); @@ -89,10 +90,14 @@ void Screen::blit() // Pinta las notificaciones notify->render(); - // Pinta el contador de FPS + // Actualiza el contador de FPS fpsCounter++; - dbg_print(0, 0, std::to_string(fps).c_str(), 255, 255, 255); - + + // Pinta en pantalla el contador de FPS + if (showFps) + { + dbg_print(0, 0, std::to_string(fps).c_str(), 255, 255, 255); + } #ifdef NO_SHADERS // Vuelve a dejar el renderizador en modo normal @@ -347,6 +352,11 @@ void Screen::checkInput() const std::string value = options->video.shaders ? "on" : "off"; showNotification("Shaders " + value); } + + else if (input->checkInput(input_showfps, DO_NOT_ALLOW_REPEAT)) + { + showFps = !showFps; + } } // Agita la pantalla diff --git a/source/common/screen.h b/source/common/screen.h index b911030..4d58add 100644 --- a/source/common/screen.h +++ b/source/common/screen.h @@ -39,6 +39,7 @@ private: Uint32 fpsTicks; // Ticks para contar los frames por segundo int fpsCounter; // Contador de frames por segundo int fps; // Frames calculados en el último segundo + bool showFps; // Indica si ha de mostrar/ocultar la información de los frames por segundo en pantalla struct effect_t {