// StartScreen.cpp (single-file SDL3 example) // Compile: g++ -std=c++20 StartScreen.cpp -o startscreen $(pkg-config --cflags --libs sdl3 SDL3_image) #pragma once #include #include #include #include #include #include #include #include struct Particle { SDL_FPoint original; // local logo coords (0..w, 0..h) — never change SDL_FPoint current; SDL_FPoint target; }; class StartScreen { public: bool running = true; StartScreen(SDL_Renderer* r); ~StartScreen(); void Update(); void Render(); void UpdateScreen(); private: enum class Phase { SHOW_LOGO, DOT, SPREAD_TO_LINE, LINE_WAIT, RUNNING, FADE_TO_LOGO, SHOW_PROPS }; float desired_cross_time = 1.8f; // seconds float extra_distance = 600.0f; // px left + right float logo_display_time = 3.2f; float props_anim_progress = 0.0f; // 0.0 → 1.0 void Init(); void StartSpreadToLine(); void StartFadeToLogo(); SDL_FPoint GetScreenOriginal(const Particle& p) const; static float Lerp(float a, float b, float t); void StartShowProps(); private: SDL_Renderer* renderer = nullptr; SDL_Surface* logo_surface = nullptr; SDL_Texture* char_texture = nullptr; SDL_Surface* props_surface = nullptr; SDL_Texture* props_texture = nullptr; std::vector particles; std::vector line_positions; int screen_w = 0, screen_h = 0; SDL_Rect logo_dest{}; SDL_FPoint logo_offset{0,0}; SDL_FPoint center_dot{0,0}; int line_y = 0; Phase phase = Phase::DOT; Uint64 phase_start = 0; Uint64 run_start_time = 0; Uint64 last_time = 0; float char_x = 0.0f; int char_frame = 0; // tunable float char_speed = 520.0f; int char_frame_width = 64; int char_height = 64; int ground_row_height = 1; // thicker = denser line float bottom_y = 0; std::mt19937 rng; }; namespace StartScreen_Event { void event_Loop(SDL_Renderer* renderer); }