refactor: migració a l'arquitectura SDL3 Callback API

Substitueix el bucle blocant main() → Director::run() → escena::run() per
SDL_AppInit/Iterate/Event/Quit. Cada escena implementa ara iterate() (un frame)
i handleEvent() (un event) sota una interfície base Scene.

- Director gestiona l'escena activa i les transicions via switchToActiveScene()
- Setup/cleanup que estava al voltant del while de run() mogut a ctor/dtor
  (música de Game/Ending/Ending2, volum de LoadingScreen)
- GlobalEvents ja no processa SDL_EVENT_QUIT (ho fa Director::handleEvent)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-13 08:49:19 +02:00
parent 714de067c8
commit c32a880b6a
21 changed files with 319 additions and 362 deletions

View File

@@ -6,11 +6,12 @@
#include <memory> // Para shared_ptr
#include <vector> // Para vector
#include "game/scenes/scene.hpp" // Para Scene
#include "utils/delta_timer.hpp" // Para DeltaTimer
class Sprite; // Forward declaration
class Surface; // Forward declaration
class Logo {
class Logo : public Scene {
public:
// --- Tipos ---
using EasingFunction = std::function<float(float)>; // Función de easing (permite lambdas)
@@ -28,10 +29,11 @@ class Logo {
// --- Constructor y Destructor ---
Logo();
~Logo() = default;
~Logo() override = default;
// --- Bucle principal ---
void run();
// --- Bucle principal (SDL3 Callback API) ---
void iterate() override;
void handleEvent(const SDL_Event& event) override;
private:
// --- Constantes de tiempo (en segundos) ---
@@ -48,7 +50,6 @@ class Logo {
// --- Métodos ---
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 updateJAILGAMES(float delta_time); // Gestiona el logo de JAILGAME (time-based)
void updateTextureColors(); // Gestiona el color de las texturas