mapcreator git · master
SDL3 2.5D game and engine using assets, with map editor
C++ 99.3%git clone https://git.christianimmanuel.de/sdl-graphics/mapcreator.gitwget https://git.christianimmanuel.de/sdl-graphics/mapcreator/archive/mapcreator.tar.gzsrc/end_screen/end_screen.hpp raw
// 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 <SDL3/SDL.h>
#include <SDL3_image/SDL_image.h>
#include <vector>
#include <array>
#include <random>
#include <cstdint>
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<LayerAsset, NUM_LAYERS> assets{};
std::array<LayerState, NUM_LAYERS> layer_state{};
std::array<Uint64, NUM_LAYERS> layer_start_tick{}; // when spreading began
std::array<Uint64, NUM_LAYERS> layer_due{}; // scheduled start tick
std::array<std::vector<EndParticle>, 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);
}