NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
Util::FrameCounter_c Class Reference

#include <game/bases/d_util_frame_counter.hpp>

Description

A bidirectional frame counter.

Definition at line 9 of file d_util_frame_counter.hpp.

Public Types

enum  Type_e {
  TYPE_ONETIME ,
  TYPE_LOOP ,
  TYPE_OSCILLATING
}
 The possible behaviors after the frame counter is finished. More...

Public Member Functions

 FrameCounter_c ()
 Constructs a new frame counter.
 ~FrameCounter_c ()
 Destroys the frame counter.
void init (f32 startFrame, f32 endFrame)
 Initializes the frame interval.
void play (f32 updateRate, Type_e type, f32 startFrame, f32 endFrame)
 Fully initializes into a valid state.
void play (f32 updateRate, Type_e type)
 Partially initializes into a valid state without initializing the frame interval.
void calc ()
 Updates the frame counter.
f32 getFrame () const
 Gets the current frame.
void setFrame (f32 frame)
 Sets the current frame.
f32 getUpdateRate () const
 Gets the update rate.
void setUpdateRate (f32 updateRate)
 Sets the update rate.
bool getFinished () const
 Gets whether the counter is finished.

Private Attributes

f32 m_frame
 The current frame in the interval [start, end].
f32 m_startFrame
 Lower bound of the frame interval.
f32 m_endFrame
 Upper bound of the frame interval.
f32 m_updateRate
 Controls the direction and rate at which the frame updates.
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.

Member Enumeration Documentation

◆ Type_e

The possible behaviors after the frame counter is finished.

Enumerator
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.

Definition at line 12 of file d_util_frame_counter.hpp.

Constructor & Destructor Documentation

◆ FrameCounter_c()

Util::FrameCounter_c::FrameCounter_c ( )

Constructs a new frame counter.

Definition at line 5 of file d_util_frame_counter.cpp.

◆ ~FrameCounter_c()

Util::FrameCounter_c::~FrameCounter_c ( )

Destroys the frame counter.

Definition at line 14 of file d_util_frame_counter.cpp.

Member Function Documentation

◆ init()

void Util::FrameCounter_c::init ( f32 startFrame,
f32 endFrame )

Initializes the frame interval.

Sets the current frame to the start frame.

Parameters
startFrameThe start frame.
endFrameThe end frame.

Definition at line 16 of file d_util_frame_counter.cpp.

◆ play() [1/2]

void Util::FrameCounter_c::play ( f32 updateRate,
Type_e type,
f32 startFrame,
f32 endFrame )

Fully initializes into a valid state.

Sets the current frame to the start frame.

Parameters
updateRateThe update rate.
typeThe play type.
startFrameThe start frame.
endFrameThe end frame.

Definition at line 23 of file d_util_frame_counter.cpp.

◆ play() [2/2]

void Util::FrameCounter_c::play ( f32 updateRate,
Type_e type )

Partially initializes into a valid state without initializing the frame interval.

Sets the current frame to the start frame.

Parameters
updateRateThe update rate.
typeThe play type.

Definition at line 30 of file d_util_frame_counter.cpp.

◆ calc()

void Util::FrameCounter_c::calc ( )

Updates the frame counter.

Sets finished to true if the counter finishes.

Definition at line 37 of file d_util_frame_counter.cpp.

◆ getFrame()

f32 Util::FrameCounter_c::getFrame ( ) const
inline

Gets the current frame.

Returns
The current frame.

Definition at line 47 of file d_util_frame_counter.hpp.

◆ setFrame()

void Util::FrameCounter_c::setFrame ( f32 frame)
inline

Sets the current frame.

Parameters
frameThe new current frame.

Definition at line 51 of file d_util_frame_counter.hpp.

◆ getUpdateRate()

f32 Util::FrameCounter_c::getUpdateRate ( ) const
inline

Gets the update rate.

Returns
The update rate.

Definition at line 55 of file d_util_frame_counter.hpp.

◆ setUpdateRate()

void Util::FrameCounter_c::setUpdateRate ( f32 updateRate)
inline

Sets the update rate.

Parameters
updateRateThe new update rate.

Definition at line 59 of file d_util_frame_counter.hpp.

◆ getFinished()

bool Util::FrameCounter_c::getFinished ( ) const
inline

Gets whether the counter is finished.

Returns
true the counter is finished, otherwise false.

Definition at line 63 of file d_util_frame_counter.hpp.

Member Data Documentation

◆ m_frame

f32 Util::FrameCounter_c::m_frame
private

The current frame in the interval [start, end].

Initialized to the start frame by init and/or play. Updated based on the update rate and type behavior in calc. Can optionally be set manually with setFrame.

Definition at line 70 of file d_util_frame_counter.hpp.

◆ m_startFrame

f32 Util::FrameCounter_c::m_startFrame
private

Lower bound of the frame interval.

Initialized by init and/or play.

Definition at line 74 of file d_util_frame_counter.hpp.

◆ m_endFrame

f32 Util::FrameCounter_c::m_endFrame
private

Upper bound of the frame interval.

Initialized by init and/or play.

Definition at line 78 of file d_util_frame_counter.hpp.

◆ m_updateRate

f32 Util::FrameCounter_c::m_updateRate
private

Controls the direction and rate at which the frame updates.

If the update rate is positive, the target frame will be the end frame. If the update rate is negative, the target frame will be the start frame. Initialized by play. Can optionally be set manually with setUpdateRate.

Definition at line 84 of file d_util_frame_counter.hpp.

◆ m_finished

bool Util::FrameCounter_c::m_finished
private

Whether or not the counter is finished.

Behavior is contingent on m_type.

Definition at line 90 of file d_util_frame_counter.hpp.

◆ m_type

Type_e Util::FrameCounter_c::m_type
private

Controls what happens to the frame when it reaches the target frame.

Definition at line 93 of file d_util_frame_counter.hpp.