Ara es pot activar o desactivar el comptador de frames per segon amb una tecla

This commit is contained in:
2024-08-26 10:52:59 +02:00
parent 4c2528ba93
commit 149e422489
2 changed files with 14 additions and 3 deletions

View File

@@ -40,6 +40,7 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input *
fpsTicks = 0; fpsTicks = 0;
fpsCounter = 0; fpsCounter = 0;
fps = 0; fps = 0;
showFps = false;
// Crea los objetos // Crea los objetos
notify = new Notify(renderer, asset->get("notify.png"), asset->get("8bithud.png"), asset->get("8bithud.txt"), asset->get("notify.wav"), options); 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 // Pinta las notificaciones
notify->render(); notify->render();
// Pinta el contador de FPS // Actualiza el contador de FPS
fpsCounter++; 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 #ifdef NO_SHADERS
// Vuelve a dejar el renderizador en modo normal // Vuelve a dejar el renderizador en modo normal
@@ -347,6 +352,11 @@ void Screen::checkInput()
const std::string value = options->video.shaders ? "on" : "off"; const std::string value = options->video.shaders ? "on" : "off";
showNotification("Shaders " + value); showNotification("Shaders " + value);
} }
else if (input->checkInput(input_showfps, DO_NOT_ALLOW_REPEAT))
{
showFps = !showFps;
}
} }
// Agita la pantalla // Agita la pantalla

View File

@@ -39,6 +39,7 @@ private:
Uint32 fpsTicks; // Ticks para contar los frames por segundo Uint32 fpsTicks; // Ticks para contar los frames por segundo
int fpsCounter; // Contador de frames por segundo int fpsCounter; // Contador de frames por segundo
int fps; // Frames calculados en el último 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 struct effect_t
{ {