// end_screen.hpp // Ending screen: 4 images revealed one by one as particle bursts from centre. // All layers are ALWAYS rendered as particles — no texture overdraw possible. // Clear color: black. Text is white. #pragma once #include #include #include #include #include #include struct EndParticle { SDL_FPoint origin; // final screen position (centred) SDL_FPoint current; // animated position }; class EndScreen { public: bool running = true; explicit EndScreen(SDL_Renderer* r); ~EndScreen(); void Update(); void Render(); void UpdateScreen(); private: enum class LayerState { WAITING, SPREADING_IN, VISIBLE }; // ── Timings (ms) ───────────────────────────────────────────────────────── // Fast burst animation, long delays between words. static constexpr Uint64 SPREAD_DURATION_MS = 420; // fast particle burst static constexpr Uint64 GAP_AFTER_0_MS = 200; // "to" → "be" (quick follow-up) static constexpr Uint64 GAP_AFTER_1_MS = 1000; // "be" → "continued" static constexpr Uint64 GAP_AFTER_2_MS = 2000; // "continued" → "nope" static constexpr Uint64 END_PAUSE_MS = 2000; // hold all visible before done void Init(); void BuildParticles(int layer_idx); void StartLayer(int idx); SDL_FPoint LayerOffset() const; // same offset for all layers (same image size) static float Lerp(float a, float b, float t); SDL_Renderer* renderer = nullptr; int screen_w = 0, screen_h = 0; static constexpr int NUM_LAYERS = 4; struct LayerAsset { SDL_Surface* surface = nullptr; // No texture needed — we render entirely via particles }; std::array assets{}; std::array layer_state{}; std::array layer_start_tick{}; // when spreading began std::array layer_due{}; // scheduled start tick std::array, NUM_LAYERS> layer_particles{}; bool end_timer_started = false; Uint64 end_timer_start = 0; Uint64 last_time = 0; std::mt19937 rng; }; namespace EndScreen_Event { void event_Loop(SDL_Renderer* renderer); }