Cambiado de showFps a showInfo

This commit is contained in:
2024-09-09 22:51:26 +02:00
parent e1fb069010
commit 824bc08077
4 changed files with 45 additions and 33 deletions

View File

@@ -39,14 +39,16 @@ Screen::Screen(SDL_Window *window, SDL_Renderer *renderer, Asset *asset, Input *
fpsCounter = 0;
fps = 0;
#ifdef DEBUG
showFps = true;
showInfo = true;
#else
showFps = false;
showInfo = false;
#endif
SDL_DisplayMode DM;
SDL_GetCurrentDisplayMode(0, &DM);
displayWidth = DM.w;
displayHeight = DM.h;
displayRefreshRate = DM.refresh_rate;
infoResolution = std::to_string(displayWidth) + " X " + std::to_string(displayHeight) + " AT " + std::to_string(displayRefreshRate) + " HZ";
// Crea los objetos
notify = new Notify(renderer, asset->get("notify.png"), asset->get("8bithud.png"), asset->get("8bithud.txt"), asset->get("notify.wav"), options);
@@ -93,23 +95,14 @@ void Screen::blit()
// Atenua la pantalla
doAttenuate();
// Pinta las notificaciones
notify->render();
// Actualiza el contador de FPS
fpsCounter++;
// Pinta en pantalla el contador de FPS
if (showFps)
{
// FPS
const std::string fpstext = std::to_string(fps) + " FPS";
dbg_print(0, 0, fpstext.c_str(), 255, 255, 255);
// Resolution
const std::string resolution = std::to_string(displayWidth) + " X " + std::to_string(displayHeight);
dbg_print(0, 8, resolution.c_str(), 255, 255, 255);
}
// Muestra información por pantalla
displayInfo();
// Muestra las notificaciones
notify->render();
#ifdef NO_SHADERS
// Vuelve a dejar el renderizador en modo normal
@@ -341,9 +334,9 @@ void Screen::checkInput()
}
#endif
if (input->checkInput(input_showfps, DO_NOT_ALLOW_REPEAT))
if (input->checkInput(input_showinfo, DO_NOT_ALLOW_REPEAT))
{
showFps = !showFps;
showInfo = !showInfo;
}
}
@@ -458,4 +451,18 @@ void Screen::updateFPS()
fps = fpsCounter;
fpsCounter = 0;
}
}
// Muestra información por pantalla
void Screen::displayInfo()
{
if (showInfo)
{
// FPS
const std::string fpstext = std::to_string(fps) + " FPS";
dbg_print(gameCanvasWidth - fpstext.length() * 8, 0, fpstext.c_str(), 255, 255, 0);
// Resolution
dbg_print(0, 0, infoResolution.c_str(), 255, 255, 0);
}
}