This commit is contained in:
2025-10-19 22:01:31 +02:00
parent 16306f2325
commit 2b4523d644
101 changed files with 2058 additions and 1564 deletions
+13 -13
View File
@@ -33,7 +33,7 @@ HiScoreTable::HiScoreTable()
backbuffer_(SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, param.game.width, param.game.height)),
fade_(std::make_unique<Fade>()),
background_(std::make_unique<Background>()),
last_time_(0),
view_area_(SDL_FRect{0, 0, param.game.width, param.game.height}),
fade_mode_(Fade::Mode::IN),
background_fade_color_(Color(0, 0, 0)) {
@@ -75,7 +75,7 @@ void HiScoreTable::render() {
SCREEN->clean(); // Limpia la pantalla
background_->render(); // Pinta el fondo
float counter_equivalent = elapsed_time_ * 60.0f; // Convertir tiempo a equivalente frame para UI
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
@@ -118,11 +118,11 @@ void HiScoreTable::checkInput() {
}
// Calcula el tiempo transcurrido desde el último frame
float HiScoreTable::calculateDeltaTime() {
const Uint64 current_time = SDL_GetTicks();
const float delta_time = static_cast<float>(current_time - last_time_) / 1000.0f; // Convertir ms a segundos
last_time_ = current_time;
return delta_time;
auto HiScoreTable::calculateDeltaTime() -> float {
const Uint64 CURRENT_TIME = SDL_GetTicks();
const float DELTA_TIME = static_cast<float>(CURRENT_TIME - last_time_) / 1000.0F; // Convertir ms a segundos
last_time_ = CURRENT_TIME;
return DELTA_TIME;
}
// Bucle para la pantalla de instrucciones
@@ -131,10 +131,10 @@ void HiScoreTable::run() {
Audio::get()->playMusic("title.ogg");
while (Section::name == Section::Name::HI_SCORE_TABLE) {
const float delta_time = calculateDeltaTime();
const float DELTA_TIME = calculateDeltaTime();
checkInput();
update(delta_time);
update(DELTA_TIME);
checkEvents(); // Tiene que ir antes del render
render();
}
@@ -262,12 +262,12 @@ void HiScoreTable::createSprites() {
// Actualiza las posiciones de los sprites de texto
void HiScoreTable::updateSprites(float delta_time) {
if (elapsed_time_ >= INIT_DELAY_S) {
const float elapsed_since_init = elapsed_time_ - INIT_DELAY_S;
int index = static_cast<int>(elapsed_since_init / ENTRY_DELAY_S);
const float ELAPSED_SINCE_INIT = elapsed_time_ - INIT_DELAY_S;
int index = static_cast<int>(ELAPSED_SINCE_INIT / ENTRY_DELAY_S);
if (index < static_cast<int>(entry_names_.size()) && index >= 0) {
// Verificar si este índice debe activarse ahora
float expected_time = index * ENTRY_DELAY_S;
if (elapsed_since_init >= expected_time && elapsed_since_init < expected_time + delta_time) {
if (ELAPSED_SINCE_INIT >= expected_time && ELAPSED_SINCE_INIT < expected_time + delta_time) {
entry_names_.at(index)->enable();
}
}
@@ -357,7 +357,7 @@ void HiScoreTable::iniEntryColors() {
// Hace brillar los nombres de la tabla de records
void HiScoreTable::glowEntryNames() {
int color_counter = static_cast<int>(elapsed_time_ * 60.0f / 5.0f); // Convertir tiempo a equivalente frame
int color_counter = static_cast<int>(elapsed_time_ * 60.0F / 5.0F); // Convertir tiempo a equivalente frame
const Color ENTRY_COLOR = getEntryColor(color_counter);
for (const auto& entry_index : Options::settings.glowing_entries) {
if (entry_index != -1) {