From 1c3d59d678a52f9a2c703320fd8590497c599ec2 Mon Sep 17 00:00:00 2001 From: Sergio Valor Date: Fri, 24 Oct 2025 08:49:09 +0200 Subject: [PATCH] =?UTF-8?q?migrat=20hiscore=5Ftable=20a=20delta=5Ftime=20d?= =?UTF-8?q?e=20manera=20correcta=20corregida=20deformaci=C3=B3=20subpixel?= =?UTF-8?q?=20de=20la=20textura=20en=20instructions=20i=20hiscore=5Ftable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/director.cpp | 2 +- source/sections/hiscore_table.cpp | 10 +++++----- source/sections/hiscore_table.hpp | 1 + source/sections/instructions.cpp | 3 ++- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/source/director.cpp b/source/director.cpp index 9b6cda3..a4a282c 100644 --- a/source/director.cpp +++ b/source/director.cpp @@ -44,7 +44,7 @@ Director::Director(int argc, std::span argv) { Section::name = Section::Name::GAME; Section::options = Section::Options::GAME_PLAY_1P; #elif _DEBUG - Section::name = Section::Name::INSTRUCTIONS; + Section::name = Section::Name::HI_SCORE_TABLE; Section::options = Section::Options::GAME_PLAY_1P; #else // NORMAL GAME Section::name = Section::Name::LOGO; diff --git a/source/sections/hiscore_table.cpp b/source/sections/hiscore_table.cpp index 6a387d2..d96d161 100644 --- a/source/sections/hiscore_table.cpp +++ b/source/sections/hiscore_table.cpp @@ -74,11 +74,11 @@ void HiScoreTable::render() { SCREEN->start(); // Prepara para empezar a dibujar en la textura de juego SCREEN->clean(); // Limpia la pantalla - background_->render(); // Pinta el fondo - float counter_equivalent = elapsed_time_ * 60.0F; // Convertir tiempo a equivalente frame para UI - view_area_.y = std::max(0.0F, param.game.height - counter_equivalent + 100); // Establece la ventana del backbuffer - SDL_RenderTexture(renderer_, backbuffer_, nullptr, &view_area_); // Copia el backbuffer al renderizador - fade_->render(); // Renderiza el fade + background_->render(); // Pinta el fondo + float scroll_offset = elapsed_time_ * SCROLL_SPEED_PPS; // Calcula el desplazamiento del scroll usando velocidad en pixels/segundo + view_area_.y = std::round(std::max(0.0F, (param.game.height + 100.0F) - scroll_offset)); // Establece la ventana del backbuffer (redondeado para evitar deformaciones) + SDL_RenderTexture(renderer_, backbuffer_, nullptr, &view_area_); // Copia el backbuffer al renderizador + fade_->render(); // Renderiza el fade SCREEN->render(); // Vuelca el contenido del renderizador en pantalla } diff --git a/source/sections/hiscore_table.hpp b/source/sections/hiscore_table.hpp index d9017f5..3cde6ca 100644 --- a/source/sections/hiscore_table.hpp +++ b/source/sections/hiscore_table.hpp @@ -38,6 +38,7 @@ class HiScoreTable { static constexpr float BACKGROUND_CHANGE_S = 150.0F / 60.0F; // Tiempo cambio fondo (≈2.5s) static constexpr float ANIM_DURATION_S = 80.0F / 60.0F; // Duración animación (≈1.33s) static constexpr float CLOUDS_SPEED = -6.0F; // Velocidad nubes (pixels/s) + static constexpr float SCROLL_SPEED_PPS = 60.0F; // Velocidad de scroll (60 pixels por segundo) // --- Objetos y punteros --- SDL_Renderer* renderer_; // El renderizador de la ventana diff --git a/source/sections/instructions.cpp b/source/sections/instructions.cpp index 61cd69d..3edf27e 100644 --- a/source/sections/instructions.cpp +++ b/source/sections/instructions.cpp @@ -343,8 +343,9 @@ void Instructions::renderLines(SDL_Renderer* renderer, SDL_Texture* texture, con void Instructions::updateBackbuffer(float delta_time) { // Establece la ventana del backbuffer usando velocidad en pixels por segundo // El scroll comienza desde (param.game.height + 100) y desciende a 0 + // IMPORTANTE: Se redondea a entero para evitar deformaciones de textura causadas por sub-pixel rendering float scroll_offset = elapsed_time_ * SCROLL_SPEED_PPS; - view_.y = std::max(0.0F, (param.game.height + 100.0F) - scroll_offset); + view_.y = std::round(std::max(0.0F, (param.game.height + 100.0F) - scroll_offset)); // Verifica si view_.y == 0 y gestiona el temporizador if (view_.y == 0.0F) {