Zappy GUI
C++ graphic client: renderer, camera, network
Loading...
Searching...
No Matches
TurnBehavior Class Reference

Interpolates an entity's visual angle from one value to another over a specified duration. More...

#include <TurnBehavior.hpp>

+ Inheritance diagram for TurnBehavior:
+ Collaboration diagram for TurnBehavior:

Public Member Functions

 TurnBehavior (VisualState &visual, float fromAngle, float toAngle, float duration)
 
void update (float dt) override
 
bool isDone () const override
 Returns true when the behavior has completed and can be removed.
 
float getDuration () const override
 Total duration of this behavior in seconds.
 
float minDuration () const override
 Minimum duration below which this behavior is skipped entirely.
 
- Public Member Functions inherited from IBehavior
virtual ~IBehavior ()=default
 

Static Private Member Functions

static float _smoothstep (float t)
 

Private Attributes

VisualState_visual
 
float _fromAngle
 
float _delta
 
float _duration
 
float _elapsed = 0.0f
 

Detailed Description

Interpolates an entity's visual angle from one value to another over a specified duration.

Definition at line 9 of file TurnBehavior.hpp.

Constructor & Destructor Documentation

◆ TurnBehavior()

TurnBehavior::TurnBehavior ( VisualState visual,
float  fromAngle,
float  toAngle,
float  duration 
)

Definition at line 5 of file TurnBehavior.cpp.

References _delta, _fromAngle, and toAngle().

+ Here is the call graph for this function:

Member Function Documentation

◆ _smoothstep()

float TurnBehavior::_smoothstep ( float  t)
staticprivate

s(t) = t²(3 - 2t) — ease-in/ease-out, zero derivative at t=0 and t=1

Definition at line 26 of file TurnBehavior.cpp.

Referenced by update().

+ Here is the caller graph for this function:

◆ getDuration()

float TurnBehavior::getDuration ( ) const
inlineoverridevirtual

Total duration of this behavior in seconds.

Implements IBehavior.

Definition at line 15 of file TurnBehavior.hpp.

References _duration.

◆ isDone()

bool TurnBehavior::isDone ( ) const
overridevirtual

Returns true when the behavior has completed and can be removed.

Implements IBehavior.

Definition at line 23 of file TurnBehavior.cpp.

References _duration, and _elapsed.

◆ minDuration()

float TurnBehavior::minDuration ( ) const
inlineoverridevirtual

Minimum duration below which this behavior is skipped entirely.

Implements IBehavior.

Definition at line 16 of file TurnBehavior.hpp.

◆ update()

void TurnBehavior::update ( float  dt)
overridevirtual

Implements IBehavior.

Definition at line 15 of file TurnBehavior.cpp.

References _delta, _duration, _elapsed, _fromAngle, _smoothstep(), _visual, and VisualState::angle.

+ Here is the call graph for this function:

Member Data Documentation

◆ _delta

float TurnBehavior::_delta
private

Definition at line 21 of file TurnBehavior.hpp.

Referenced by TurnBehavior(), and update().

◆ _duration

float TurnBehavior::_duration
private

Definition at line 22 of file TurnBehavior.hpp.

Referenced by getDuration(), isDone(), and update().

◆ _elapsed

float TurnBehavior::_elapsed = 0.0f
private

Definition at line 23 of file TurnBehavior.hpp.

Referenced by isDone(), and update().

◆ _fromAngle

float TurnBehavior::_fromAngle
private

Definition at line 20 of file TurnBehavior.hpp.

Referenced by TurnBehavior(), and update().

◆ _visual

VisualState& TurnBehavior::_visual
private

Definition at line 19 of file TurnBehavior.hpp.

Referenced by update().


The documentation for this class was generated from the following files: