fix: el cicle de color de credits.cpp
This commit is contained in:
@@ -44,7 +44,7 @@ Director::Director(int argc, std::span<char*> argv) {
|
||||
Section::name = Section::Name::GAME;
|
||||
Section::options = Section::Options::GAME_PLAY_1P;
|
||||
#elif _DEBUG
|
||||
Section::name = Section::Name::LOGO;
|
||||
Section::name = Section::Name::CREDITS;
|
||||
Section::options = Section::Options::GAME_PLAY_1P;
|
||||
#else // NORMAL GAME
|
||||
Section::name = Section::Name::LOGO;
|
||||
|
||||
@@ -111,7 +111,7 @@ void Credits::update(float delta_time) {
|
||||
Audio::update(); // Actualiza el objeto audio
|
||||
|
||||
tiled_bg_->update(ADJUSTED_DELTA_TIME);
|
||||
cycleColors();
|
||||
cycleColors(ADJUSTED_DELTA_TIME);
|
||||
balloon_manager_->update(ADJUSTED_DELTA_TIME);
|
||||
updateTextureDstRects(ADJUSTED_DELTA_TIME);
|
||||
throwBalloons(ADJUSTED_DELTA_TIME);
|
||||
@@ -505,11 +505,15 @@ void Credits::resetVolume() const {
|
||||
Audio::get()->setMusicVolume(Options::audio.music.volume);
|
||||
}
|
||||
|
||||
// Cambia el color del fondo
|
||||
void Credits::cycleColors() {
|
||||
// Cambia el color del fondo (time-based)
|
||||
void Credits::cycleColors(float delta_time) {
|
||||
constexpr int UPPER_LIMIT = 140; // Límite superior
|
||||
constexpr int LOWER_LIMIT = 30; // Límite inferior
|
||||
|
||||
// Factor para escalar los valores de incremento.
|
||||
// Asumimos que los valores originales estaban balanceados para 60 FPS.
|
||||
const float FRAME_ADJUSTMENT = delta_time * 60.0F;
|
||||
|
||||
// Inicializar valores RGB si es la primera vez
|
||||
if (credits_state_.r == 255.0F && credits_state_.g == 0.0F && credits_state_.b == 0.0F && credits_state_.step_r == -0.5F) {
|
||||
credits_state_.r = static_cast<float>(UPPER_LIMIT);
|
||||
@@ -518,21 +522,33 @@ void Credits::cycleColors() {
|
||||
}
|
||||
|
||||
// Ajustar valores de R
|
||||
credits_state_.r += credits_state_.step_r;
|
||||
if (credits_state_.r >= UPPER_LIMIT || credits_state_.r <= LOWER_LIMIT) {
|
||||
credits_state_.r += credits_state_.step_r * FRAME_ADJUSTMENT;
|
||||
if (credits_state_.r >= UPPER_LIMIT) {
|
||||
credits_state_.r = UPPER_LIMIT; // Clamp para evitar que se pase
|
||||
credits_state_.step_r = -credits_state_.step_r; // Cambia de dirección al alcanzar los límites
|
||||
} else if (credits_state_.r <= LOWER_LIMIT) {
|
||||
credits_state_.r = LOWER_LIMIT; // Clamp para evitar que se pase
|
||||
credits_state_.step_r = -credits_state_.step_r;
|
||||
}
|
||||
|
||||
// Ajustar valores de G
|
||||
credits_state_.g += credits_state_.step_g;
|
||||
if (credits_state_.g >= UPPER_LIMIT || credits_state_.g <= LOWER_LIMIT) {
|
||||
credits_state_.g += credits_state_.step_g * FRAME_ADJUSTMENT;
|
||||
if (credits_state_.g >= UPPER_LIMIT) {
|
||||
credits_state_.g = UPPER_LIMIT;
|
||||
credits_state_.step_g = -credits_state_.step_g; // Cambia de dirección al alcanzar los límites
|
||||
} else if (credits_state_.g <= LOWER_LIMIT) {
|
||||
credits_state_.g = LOWER_LIMIT;
|
||||
credits_state_.step_g = -credits_state_.step_g;
|
||||
}
|
||||
|
||||
// Ajustar valores de B
|
||||
credits_state_.b += credits_state_.step_b;
|
||||
if (credits_state_.b >= UPPER_LIMIT || credits_state_.b <= LOWER_LIMIT) {
|
||||
credits_state_.b += credits_state_.step_b * FRAME_ADJUSTMENT;
|
||||
if (credits_state_.b >= UPPER_LIMIT) {
|
||||
credits_state_.b = UPPER_LIMIT;
|
||||
credits_state_.step_b = -credits_state_.step_b; // Cambia de dirección al alcanzar los límites
|
||||
} else if (credits_state_.b <= LOWER_LIMIT) {
|
||||
credits_state_.b = LOWER_LIMIT;
|
||||
credits_state_.step_b = -credits_state_.step_b;
|
||||
}
|
||||
|
||||
// Aplicar el color, redondeando a enteros antes de usar
|
||||
|
||||
@@ -129,12 +129,10 @@ class Credits {
|
||||
void renderPlayers(); // Renderiza los jugadores
|
||||
|
||||
// --- Métodos de lógica del juego ---
|
||||
void throwBalloons(); // Lanzar globos al escenario (frame-based)
|
||||
void throwBalloons(float delta_time); // Lanzar globos al escenario (time-based)
|
||||
void initPlayers(); // Inicializar jugadores
|
||||
void updateAllFades(); // Actualizar estados de fade (frame-based)
|
||||
void updateAllFades(float delta_time); // Actualizar estados de fade (time-based)
|
||||
void cycleColors(); // Cambiar colores de fondo
|
||||
void cycleColors(float delta_time); // Cambiar colores de fondo
|
||||
void updatePlayers(float delta_time); // Actualza los jugadores (time-based)
|
||||
|
||||
// --- Métodos de interfaz ---
|
||||
|
||||
Reference in New Issue
Block a user