group2 0.1.0
CSE 125 Group 2
Loading...
Searching...
No Matches
HudTween.hpp
Go to the documentation of this file.
1
3
4#pragma once
5
6#include <cstdint>
7
9using HudEaseFn = float (*)(float t);
10
11// ── Built-in easing functions ───────────────────────────────────────────────
12float easeLinear(float t);
13float easeInQuad(float t);
14float easeOutQuad(float t);
15float easeInOutQuad(float t);
16float easeOutBack(float t);
17float easeOutElastic(float t);
18
19// ── Tween pool ──────────────────────────────────────────────────────────────
20
23{
24 float* target = nullptr;
25 float from = 0.f;
26 float to = 0.f;
27 float duration = 0.f;
28 float elapsed = 0.f;
30 bool active = false;
31};
32
35{
36public:
37 static constexpr int k_maxTweens = 64;
38
40 void tween(float* target, float to, float duration, HudEaseFn ease = easeOutQuad);
41
43 void tween(float* target, float from, float to, float duration, HudEaseFn ease = easeOutQuad);
44
46 void cancel(float* target);
47
49 void update(float dt);
50
51private:
53
55 HudTweenEntry* findSlot(float* target);
56};
float easeLinear(float t)
Definition HudTween.cpp:11
float easeInQuad(float t)
Definition HudTween.cpp:16
float(*)(float t) HudEaseFn
Easing function signature: maps t ∈ [0,1] → [0,1].
Definition HudTween.hpp:9
float easeInOutQuad(float t)
Definition HudTween.cpp:26
float easeOutQuad(float t)
Definition HudTween.cpp:21
float easeOutBack(float t)
Definition HudTween.cpp:31
float easeOutElastic(float t)
Definition HudTween.cpp:39
Fixed-size tween pool. No heap allocations.
Definition HudTween.hpp:35
static constexpr int k_maxTweens
Definition HudTween.hpp:37
void tween(float *target, float to, float duration, HudEaseFn ease=easeOutQuad)
Start or replace a tween on target from its current value to to.
Definition HudTween.cpp:66
void update(float dt)
Tick all active tweens by dt seconds.
Definition HudTween.cpp:94
void cancel(float *target)
Cancel any active tween targeting target.
Definition HudTween.cpp:87
HudTweenEntry * findSlot(float *target)
Find an existing tween on target, or the first free slot.
Definition HudTween.cpp:51
HudTweenEntry entries_[k_maxTweens]
Definition HudTween.hpp:52
One active interpolation targeting a float.
Definition HudTween.hpp:23
float duration
Definition HudTween.hpp:27
bool active
Definition HudTween.hpp:30
float elapsed
Definition HudTween.hpp:28
float from
Definition HudTween.hpp:25
HudEaseFn ease
Definition HudTween.hpp:29
float * target
Definition HudTween.hpp:24
float to
Definition HudTween.hpp:26