50 lines
884 B
C++
50 lines
884 B
C++
#pragma once
|
|
#include <SDL3/SDL.h>
|
|
|
|
#include <vector>
|
|
|
|
enum class SyncState {
|
|
Idle,
|
|
LeftReady,
|
|
RightReady,
|
|
Synced,
|
|
ClearFlash
|
|
};
|
|
|
|
class SyncLineRenderer {
|
|
public:
|
|
SyncLineRenderer();
|
|
|
|
void SetRect(const SDL_FRect& rect);
|
|
void SetState(SyncState state);
|
|
void TriggerClearFlash();
|
|
|
|
void Update(float deltaTime);
|
|
void Render(SDL_Renderer* renderer);
|
|
|
|
private:
|
|
struct SyncParticle {
|
|
float y;
|
|
float speed;
|
|
float alpha;
|
|
};
|
|
|
|
SDL_FRect m_rect{};
|
|
SyncState m_state;
|
|
|
|
float m_flashTimer;
|
|
float m_time;
|
|
|
|
float m_pulseTime{0.0f};
|
|
float m_spawnAcc{0.0f};
|
|
std::vector<SyncParticle> m_particles;
|
|
|
|
static constexpr float FLASH_DURATION = 0.15f;
|
|
static constexpr size_t MAX_PARTICLES = 64;
|
|
|
|
void SpawnParticle();
|
|
void SpawnBurst(int count);
|
|
|
|
SDL_Color GetBaseColor() const;
|
|
};
|