#pragma once #include #include // Para shared_ptr #include // Para string #include // 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: // --- Estados --- enum class State { REVEALING_TEXT, PAUSE_1, REVEALING_TEXT_2, PAUSE_2, REVEALING_TEXT_3, PAUSE_3, DISPLAYING_WITH_SHINE, FADING_OUT, EXITING }; // --- 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 struct Captions { std::string label; // Texto a escribir Uint8 color; // Color del texto }; // --- Objetos y punteros --- std::shared_ptr text_surface_; // Textura para dibujar el texto std::shared_ptr cover_surface_; // Textura para cubrir el texto std::shared_ptr shining_sprite_; // Sprite para el brillo del corazón // --- Variables --- std::unique_ptr 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) float current_delta_ = 0.0F; // Delta time del frame actual std::vector texts_; // Vector con los textos // --- Funciones --- void update(); // Actualiza las variables void render(); // Dibuja en pantalla static void checkEvents(); // Comprueba el manejador de eventos static void checkInput(); // 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 };