8#include <unordered_map>
44 const char*
id, SDL_Point frameSize,
const char* texPath,
int speed = 100,
45 bool isLooping =
true,
bool isReversible =
false
97 const char*
id,
const char* texPath,
int speed = 100,
const bool isLooping =
true,
98 const bool isReversible =
false
107 addEdge(
const char* idFrom,
const char* idTo, std::vector<std::shared_ptr<bool>> conditions);
115 std::shared_ptr<Animation> currentAnimation;
120 std::unordered_map<const char*, std::shared_ptr<Animation>> animations;
121 std::unordered_map<const char*, std::unordered_map<const char*, Edge>> adjMatrix;
Defines the component for rendering a static or animated sprite.
Represents a single, self-contained animation sequence.
Definition Animator.h:20
bool loop
Whether the animation should loop upon completion.
Definition Animator.h:25
bool reversible
If true, the animation plays forwards then backwards.
Definition Animator.h:26
int frames
The number of frames in the sprite sheet.
Definition Animator.h:22
SDL_Texture * texture
The texture containing the animation frames.
Definition Animator.h:23
int speed
The delay in milliseconds between frames.
Definition Animator.h:24
const char * id
Unique identifier for the animation.
Definition Animator.h:21
Defines a transition edge between two animations in the state machine.
Definition Animator.h:53
const bool canTraverse() const
Checks if all conditions for traversing this edge are met.
Definition Animator.cpp:49
std::vector< std::shared_ptr< bool > > conditions
Definition Animator.h:54
Manages sprite sheet animations and transitions between them using a state machine.
Definition Animator.h:15
std::string getCurrAnimID()
Gets the ID of the currently playing animation.
Definition Animator.cpp:111
void addEdge(const char *idFrom, const char *idTo, std::vector< std::shared_ptr< bool > > conditions)
Defines a conditional transition between two animations.
Definition Animator.cpp:102
void draw() override
Draws the current frame of the active animation.
Definition Animator.cpp:93
void init() override
Initializes the Animator component, acquiring the entity's Sprite component.
Definition Animator.cpp:62
void addAnimation(const char *id, const char *texPath, int speed=100, const bool isLooping=true, const bool isReversible=false)
Adds a new animation state to the animator's state machine.
Definition Animator.cpp:95
void update() override
Updates the current animation state, checking for transitions and advancing the frame.
Definition Animator.cpp:69
The base class for all components in the ECS.
Definition ECS.h:53
A component that gives an entity a visual representation using a texture.
Definition Sprites.h:18