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

Interpolates an entity's visual position from one tile to another. Handles toroidal wrap-around by teleporting the visual position to the entry edge mid-move. More...

#include <MoveBehavior.hpp>

+ Inheritance diagram for MoveBehavior:
+ Collaboration diagram for MoveBehavior:

Public Member Functions

 MoveBehavior (VisualState &visual, int fromX, int fromY, int toX, int toY, int mapW, int mapH, float tileSize, 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
 
Vector3 _from
 
Vector3 _to
 
float _duration
 
float _elapsed = 0.0f
 
bool _wraps
 
Vector3 _wrapExit = {}
 
Vector3 _wrapEntry = {}
 
float _splitT = 0.5f
 

Detailed Description

Interpolates an entity's visual position from one tile to another. Handles toroidal wrap-around by teleporting the visual position to the entry edge mid-move.

Definition at line 11 of file MoveBehavior.hpp.

Constructor & Destructor Documentation

◆ MoveBehavior()

MoveBehavior::MoveBehavior ( VisualState visual,
int  fromX,
int  fromY,
int  toX,
int  toY,
int  mapW,
int  mapH,
float  tileSize,
float  duration 
)

Definition at line 7 of file MoveBehavior.cpp.

References _from, _splitT, _to, _visual, _wrapEntry, _wrapExit, _wraps, VisualState::pos, and RenderingHelper::tileToWorld().

+ Here is the call graph for this function:

Member Function Documentation

◆ _smoothstep()

float MoveBehavior::_smoothstep ( float  t)
staticprivate

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

Definition at line 79 of file MoveBehavior.cpp.

Referenced by update().

+ Here is the caller graph for this function:

◆ getDuration()

float MoveBehavior::getDuration ( ) const
inlineoverridevirtual

Total duration of this behavior in seconds.

Implements IBehavior.

Definition at line 18 of file MoveBehavior.hpp.

References _duration.

◆ isDone()

bool MoveBehavior::isDone ( ) const
overridevirtual

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

Implements IBehavior.

Definition at line 76 of file MoveBehavior.cpp.

References _duration, and _elapsed.

◆ minDuration()

float MoveBehavior::minDuration ( ) const
inlineoverridevirtual

Minimum duration below which this behavior is skipped entirely.

Implements IBehavior.

Definition at line 19 of file MoveBehavior.hpp.

◆ update()

void MoveBehavior::update ( float  dt)
overridevirtual

Implements IBehavior.

Definition at line 50 of file MoveBehavior.cpp.

References _duration, _elapsed, _from, _smoothstep(), _splitT, _to, _visual, _wrapEntry, _wrapExit, _wraps, and VisualState::pos.

+ Here is the call graph for this function:

Member Data Documentation

◆ _duration

float MoveBehavior::_duration
private

Definition at line 25 of file MoveBehavior.hpp.

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

◆ _elapsed

float MoveBehavior::_elapsed = 0.0f
private

Definition at line 26 of file MoveBehavior.hpp.

Referenced by isDone(), and update().

◆ _from

Vector3 MoveBehavior::_from
private

Definition at line 23 of file MoveBehavior.hpp.

Referenced by MoveBehavior(), and update().

◆ _splitT

float MoveBehavior::_splitT = 0.5f
private

Definition at line 30 of file MoveBehavior.hpp.

Referenced by MoveBehavior(), and update().

◆ _to

Vector3 MoveBehavior::_to
private

Definition at line 24 of file MoveBehavior.hpp.

Referenced by MoveBehavior(), and update().

◆ _visual

VisualState& MoveBehavior::_visual
private

Definition at line 22 of file MoveBehavior.hpp.

Referenced by MoveBehavior(), and update().

◆ _wrapEntry

Vector3 MoveBehavior::_wrapEntry = {}
private

Definition at line 29 of file MoveBehavior.hpp.

Referenced by MoveBehavior(), and update().

◆ _wrapExit

Vector3 MoveBehavior::_wrapExit = {}
private

Definition at line 28 of file MoveBehavior.hpp.

Referenced by MoveBehavior(), and update().

◆ _wraps

bool MoveBehavior::_wraps
private

Definition at line 27 of file MoveBehavior.hpp.

Referenced by MoveBehavior(), and update().


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