migrat correctament a delta_time credits.cpp i eliminat un bug que feia que si no pasaves a ma el final, no acabara mai

This commit is contained in:
2025-10-24 10:10:55 +02:00
parent 1c3d59d678
commit 4b732c189c
3 changed files with 46 additions and 36 deletions

View File

@@ -32,12 +32,14 @@ class Credits {
void initVars(); // Inicializa variables
void startCredits(); // Inicializa mas variables
// --- Constantes de clase ---
// --- Constantes de clase (time-based) ---
static constexpr int PLAY_AREA_HEIGHT = 200;
static constexpr float FAST_FORWARD_MULTIPLIER = 6.0F;
static constexpr float BLACK_RECT_INTERVAL_S = 4.0F / 60.0F; // ~0.0667s
static constexpr float BLACK_RECT_INTERVAL_S = 4.0F / 60.0F; // ~0.0667s (cada 4 frames a 60fps)
static constexpr float FRAMES_PER_SECOND = 60.0F;
static constexpr int HORIZONTAL_SPEED = 2;
static constexpr float MAX_TIME_AFTER_LOGO_S = 1000.0F / 60.0F; // ~16.67s (límite para evitar bucle infinito)
static constexpr float PRE_FADE_DELAY_S = 400.0F / 60.0F; // ~6.67s (retraso antes del fade final)
// --- Objetos principales ---
std::unique_ptr<BalloonManager> balloon_manager_; // Gestión de globos
@@ -50,11 +52,11 @@ class Credits {
SDL_Texture* text_texture_; // Textura con el texto de créditos
SDL_Texture* canvas_; // Textura donde se dibuja todo
// --- Temporización y contadores ---
Uint64 last_time_ = 0; // Último tiempo registrado para deltaTime
float counter_ = 0.0F; // Contador principal de lógica
float counter_pre_fade_ = 0.0F; // Activación del fundido final
float counter_prevent_endless_ = 0.0F; // Prevención de bucle infinito
// --- Temporización (time-based puro) ---
Uint64 last_time_ = 0; // Último tiempo registrado para deltaTime
float elapsed_time_balloons_ = 0.0F; // Tiempo acumulado para lanzamiento de globos (segundos)
float counter_pre_fade_ = 0.0F; // Tiempo antes de activar fundido final (segundos)
float time_since_logo_positioned_ = 0.0F; // Tiempo desde que el logo llegó a su posición (segundos)
float current_step_ = 0.0F;
int total_steps_ = 1;
bool initialized_ = false;