5#define NUM_LOOP_STATES 3
6#define NUM_BACK_FORTH_STATES 4
11 enum class FlashState {
18 float interpolation_a = 0.0f;
19 std::map<FlashState, float> speeds;
21 FlashState currentSpeedIndex = FlashState::FLASH_OUT;
30 const std::vector<float>& flashTimes,
TazColor flashC,
int _reps = 0) :
Animation(0, 0, f, s, _type)
32 speeds[FlashState::FLASH_OUT] = flashTimes[0];
33 speeds[FlashState::EASE_IN] = flashTimes[1];
34 speeds[FlashState::FLASH_IN] = flashTimes[2];
35 speeds[FlashState::EASE_OUT] = flashTimes[3];
41 const std::vector<float>& flashTimes,
TazColor flashC,
int _reps = 0)
44 speeds[FlashState::FLASH_OUT] = flashTimes[0];
45 speeds[FlashState::EASE_IN] = flashTimes[1];
46 speeds[FlashState::FLASH_IN] = flashTimes[2];
47 speeds[FlashState::EASE_OUT] = flashTimes[3];
52 void advanceFrame(
float deltaTime) {
53 unsigned short prev_frame_index = cur_frame_index;
55 speed = speeds[currentSpeedIndex];
56 switch (currentSpeedIndex) {
57 case FlashState::FLASH_OUT:
60 case FlashState::EASE_IN:
62 interpolation_a = cur_frame_index_f - cur_frame_index;
64 case FlashState::FLASH_IN:
67 case FlashState::EASE_OUT:
69 interpolation_a = 1 - (cur_frame_index_f - cur_frame_index);
73 case Animation::animType::ANIMTYPE_BACK_FORTH:
75 cur_frame_index_f += speed * deltaTime;
76 cur_frame_index =
static_cast<unsigned short>(cur_frame_index_f);
78 if (cur_frame_index >= NUM_BACK_FORTH_STATES) {
81 if (reps && times_played >= reps) {
86 if (prev_frame_index != cur_frame_index) {
87 frame_times_played = 1;
88 if ((
static_cast<int>(currentSpeedIndex) ) < NUM_BACK_FORTH_STATES)
89 currentSpeedIndex =
static_cast<FlashState
>(
static_cast<int>(cur_frame_index));
95 case Animation::animType::ANIMTYPE_LOOPED:
96 case Animation::animType::ANIMTYPE_PLAY_N_TIMES:
97 cur_frame_index_f += speed * deltaTime;
98 cur_frame_index =
static_cast<unsigned short>(cur_frame_index_f);
101 if (prev_frame_index != cur_frame_index) {
102 frame_times_played = 1;
103 if (
static_cast<int>(currentSpeedIndex) < NUM_LOOP_STATES)
104 currentSpeedIndex =
static_cast<FlashState
>(
static_cast<int>(cur_frame_index));
107 frame_times_played++;
110 if (cur_frame_index >= NUM_LOOP_STATES)
114 if (reps && times_played >= reps) {
120 case Animation::animType::ANIMTYPE_NONE:
125 std::vector<float> getSpeedsAsVector()
const {
126 std::vector<float> speedsVector(4);
129 speedsVector[0] = speeds.at(FlashState::FLASH_OUT);
130 speedsVector[1] = speeds.at(FlashState::EASE_IN);
131 speedsVector[2] = speeds.at(FlashState::FLASH_IN);
132 speedsVector[3] = speeds.at(FlashState::EASE_OUT);
Definition FlashAnimation.h:10