Afegit param.game.speed i retocats els update() de les seccions

This commit is contained in:
2025-03-12 10:06:38 +01:00
parent 90313da3ce
commit 5ccd7eebcd
13 changed files with 471 additions and 406 deletions

View File

@@ -15,7 +15,7 @@
#include "jail_audio.h" // Para JA_GetMusicState, JA_Music_state
#include "lang.h" // Para getText
#include "manage_hiscore_table.h" // Para HiScoreEntry
#include "global_events.h" // Para handleEvent
#include "global_events.h" // Para handleEvent
#include "options.h" // Para Options, OptionsGame, options
#include "param.h" // Para Param, param, ParamGame, ParamFade
#include "path_sprite.h" // Para PathSprite, Path, PathType
@@ -58,28 +58,17 @@ HiScoreTable::~HiScoreTable()
// Actualiza las variables
void HiScoreTable::update()
{
constexpr int TICKS_SPEED = 15;
if (SDL_GetTicks() - ticks_ > TICKS_SPEED)
if (SDL_GetTicks() - ticks_ > param.game.speed)
{
// Actualiza el contador de ticks
ticks_ = SDL_GetTicks();
// Mantiene la música sonando
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
{
JA_PlayMusic(Resource::get()->getMusic("title.ogg"));
}
updateMusic();
// Actualiza las posiciones de los sprites de texto
updateSprites();
// Actualiza el objeto screen
Screen::get()->update();
// Actualiza las variables de globalInputs
globalInputs::update();
// Actualiza el fondo
background_->update();
@@ -87,21 +76,16 @@ void HiScoreTable::update()
updateFade();
// Gestiona el contador y sus eventos
counter_++;
if (counter_ == 150)
{
background_->setColor(background_fade_color_.darken());
background_->setAlpha(96);
}
if (counter_ == COUNTER_END_)
{
fade_->activate();
}
updateCounter();
// Dibuja los sprites en la textura
fillTexture();
// Actualiza el objeto screen
Screen::get()->update();
// Actualiza las variables de globalInputs
globalInputs::update();
}
}
@@ -421,12 +405,38 @@ void HiScoreTable::iniEntryColors()
// Hace brillar los nombres de la tabla de records
void HiScoreTable::glowEntryNames()
{
const Color entry_color = getEntryColor(counter_ / 5);
for (const auto& entry_index : options.game.last_hi_score_entry)
{
if (entry_index != -1)
{
entry_names_.at(entry_index)->getTexture()->setColor(entry_color);
}
}
const Color entry_color = getEntryColor(counter_ / 5);
for (const auto &entry_index : options.game.last_hi_score_entry)
{
if (entry_index != -1)
{
entry_names_.at(entry_index)->getTexture()->setColor(entry_color);
}
}
}
// Gestiona la musica
void HiScoreTable::updateMusic()
{
if ((JA_GetMusicState() == JA_MUSIC_INVALID) || (JA_GetMusicState() == JA_MUSIC_STOPPED))
{
JA_PlayMusic(Resource::get()->getMusic("title.ogg"));
}
}
// Gestiona el contador
void HiScoreTable::updateCounter()
{
counter_++;
if (counter_ == 150)
{
background_->setColor(background_fade_color_.darken());
background_->setAlpha(96);
}
if (counter_ == COUNTER_END_)
{
fade_->activate();
}
}