78 lines
3.5 KiB
C++
78 lines
3.5 KiB
C++
#pragma once
|
|
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <memory> // Para shared_ptr
|
|
#include <string> // Para string
|
|
#include <vector> // Para vector
|
|
class SurfaceAnimatedSprite; // lines 11-11
|
|
class Surface;
|
|
class DeltaTimer;
|
|
|
|
class Credits {
|
|
public:
|
|
// --- Constructor y Destructor ---
|
|
Credits();
|
|
~Credits() = default;
|
|
|
|
// --- Bucle principal ---
|
|
void run();
|
|
|
|
private:
|
|
// --- Tipos anidados ---
|
|
enum class State {
|
|
REVEALING_TEXT,
|
|
PAUSE_1,
|
|
REVEALING_TEXT_2,
|
|
PAUSE_2,
|
|
REVEALING_TEXT_3,
|
|
PAUSE_3,
|
|
DISPLAYING_WITH_SHINE,
|
|
FADING_OUT,
|
|
EXITING
|
|
};
|
|
|
|
struct Captions {
|
|
std::string label; // Texto a escribir
|
|
Uint8 color{0}; // Color del texto
|
|
};
|
|
|
|
// --- Constantes de tiempo (basado en 60 FPS) ---
|
|
static constexpr float REVEAL_PHASE_1_DURATION = 3.733F; // 224 frames @ 60fps
|
|
static constexpr float PAUSE_DURATION = 1.667F; // 100 frames @ 60fps
|
|
static constexpr float REVEAL_PHASE_2_DURATION = 5.333F; // 320 frames (544-224) @ 60fps
|
|
static constexpr float REVEAL_PHASE_3_DURATION = 2.133F; // 128 frames (672-544) @ 60fps
|
|
static constexpr float DISPLAY_WITH_SHINE_DURATION = 7.967F; // 478 frames (1150-672) @ 60fps
|
|
static constexpr float FADE_OUT_DURATION = 0.833F; // 50 frames (1200-1150) @ 60fps
|
|
static constexpr float TOTAL_DURATION = 20.0F; // 1200 frames @ 60fps
|
|
static constexpr float SHINE_START_TIME = 12.833F; // 770 frames @ 60fps
|
|
static constexpr float FADE_OUT_START = 19.167F; // 1150 frames @ 60fps
|
|
static constexpr float REVEAL_SPEED = 60.0F; // counter equivalente por segundo @ 60fps
|
|
|
|
// --- Métodos privados ---
|
|
void update(); // Actualiza las variables
|
|
void render(); // Dibuja en pantalla
|
|
static void handleEvents(); // Comprueba el manejador de eventos
|
|
static void handleInput(); // Comprueba las entradas
|
|
void updateState(float delta_time); // Actualiza la máquina de estados
|
|
void transitionToState(State new_state); // Transición entre estados
|
|
void iniTexts(); // Inicializa los textos
|
|
void fillTexture(); // Escribe el texto en la textura
|
|
|
|
// --- Variables miembro ---
|
|
// Recursos gráficos
|
|
std::shared_ptr<Surface> text_surface_; // Textura para dibujar el texto
|
|
std::shared_ptr<Surface> cover_surface_; // Textura para cubrir el texto
|
|
std::shared_ptr<SurfaceAnimatedSprite> shining_sprite_; // Sprite para el brillo del corazón
|
|
|
|
// Temporizadores y estado
|
|
std::unique_ptr<DeltaTimer> delta_timer_; // Temporizador delta para time-based update
|
|
State state_{State::REVEALING_TEXT}; // Estado actual
|
|
float state_time_{0.0F}; // Tiempo acumulado en el estado actual
|
|
float total_time_{0.0F}; // Tiempo total acumulado
|
|
float reveal_time_{0.0F}; // Tiempo acumulado solo durante revelación (se congela en pausas)
|
|
|
|
// Textos
|
|
std::vector<Captions> texts_; // Vector con los textos
|
|
};
|