NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
d_util_frame_counter.cpp
1#include <game/bases/d_util_frame_counter.hpp>
2
3namespace Util {
4
6 : m_frame(0.0f),
7 m_startFrame(0.0f),
8 m_endFrame(0.0f),
9 m_updateRate(0.0f),
11 m_finished = true;
12}
13
15
16void FrameCounter_c::init(f32 startFrame, f32 endFrame) {
17 m_startFrame = startFrame;
18 m_endFrame = endFrame;
19
20 m_frame = startFrame;
21}
22
23void FrameCounter_c::play(f32 updateRate, Type_e type, f32 startFrame, f32 endFrame) {
24 m_startFrame = startFrame;
25 m_endFrame = endFrame;
26
27 play(updateRate, type);
28}
29
30void FrameCounter_c::play(f32 updateRate, Type_e type) {
31 m_updateRate = updateRate;
32 m_type = type;
33
35}
36
39 m_finished = false;
40
41 // Target frame is the end frame
42 if (m_updateRate >= 0.0f && m_frame >= m_endFrame) {
43 m_finished = true;
44
45 switch (m_type) {
46 case TYPE_ONETIME:
48 break;
49 case TYPE_LOOP:
51 break;
54 m_updateRate *= -1.0f;
55 break;
56 default:
57 break;
58 }
59 }
60
61 // Target frame is the start frame
62 if (m_updateRate <= 0.0f && m_frame <= m_startFrame) {
63 m_finished = true;
64
65 switch (m_type) {
66 case TYPE_ONETIME:
68 break;
69 case TYPE_LOOP:
71 break;
74 m_updateRate *= -1.0f;
75 break;
76 default:
77 break;
78 }
79 }
80}
81
82} // namespace Util
f32 m_startFrame
Lower bound of the frame interval.
void calc()
Updates the frame counter.
FrameCounter_c()
Constructs a new frame counter.
void play(f32 updateRate, Type_e type, f32 startFrame, f32 endFrame)
Fully initializes into a valid state.
~FrameCounter_c()
Destroys the frame counter.
void init(f32 startFrame, f32 endFrame)
Initializes the frame interval.
f32 m_frame
The current frame in the interval [start, end].
bool m_finished
Whether or not the counter is finished.
Type_e m_type
Controls what happens to the frame when it reaches the target frame.
f32 m_updateRate
Controls the direction and rate at which the frame updates.
f32 m_endFrame
Upper bound of the frame interval.
Type_e
The possible behaviors after the frame counter is finished.
@ TYPE_ONETIME
Locks the frame to the target frame.
@ TYPE_LOOP
Continues counting in the same direction.
@ TYPE_OSCILLATING
Continues counting in the opposite direction.