1 #ifndef ANIMATION_RENDER_COMPONENT_HPP 2 #define ANIMATION_RENDER_COMPONENT_HPP 4 #include <unordered_map> 7 #include "FilePaths.hpp" 8 #include "RenderComponent.hpp" 64 std::unordered_map<unsigned int, Animation> map);
74 std::unordered_map<unsigned int, Animation>
stateMap;
std::shared_ptr< SDL_Rect > GetRectForFrame(unsigned int frame)
Gets the rect of the spritesheet representing the current frame.
Definition: AnimationRenderComponent.cpp:19
unsigned int srcY
The source rect's y coordinate for this animation.
Definition: AnimationRenderComponent.hpp:18
A RenderComponent class.
Definition: RenderComponent.hpp:13
unsigned int FPS
The frames per second of this animation.
Definition: AnimationRenderComponent.hpp:31
void SwitchState(unsigned int state)
Switches the current animation state.
Definition: AnimationRenderComponent.cpp:37
unsigned int srcX
The source rect's x coordinate for this animation.
Definition: AnimationRenderComponent.hpp:16
std::string spriteSheet
The spritesheet for this animation.
Definition: AnimationRenderComponent.hpp:13
unsigned int srcW
The source rect's width for this animation.
Definition: AnimationRenderComponent.hpp:20
unsigned int numFrames
The number of frames of this animation.
Definition: AnimationRenderComponent.hpp:25
unsigned int srcH
The source rect's height for this animation.
Definition: AnimationRenderComponent.hpp:22
std::unordered_map< unsigned int, Animation > stateMap
The map of state IDs to animations.
Definition: AnimationRenderComponent.hpp:74
unsigned int curIndex
The current frame of the animation.
Definition: AnimationRenderComponent.hpp:80
AnimationRenderComponent(std::unordered_map< unsigned int, Animation > map)
Constructs a new AnimationRenderComponent.
Definition: AnimationRenderComponent.cpp:31
Animation(const std::string &spriteSheet, unsigned int srcX, unsigned int srcY, unsigned int srcW, unsigned int srcH, unsigned int numFrames, unsigned int frameDifference, unsigned int FPS)
Constructs a new animation.
Definition: AnimationRenderComponent.cpp:6
An AnimationRenderComponent class.
Definition: AnimationRenderComponent.hpp:60
Struct for a single animation.
Definition: AnimationRenderComponent.hpp:11
unsigned int curState
The current state of this animation eg: running.
Definition: AnimationRenderComponent.hpp:77
float timer
Times when the next frame of the animation is needed.
Definition: AnimationRenderComponent.hpp:83
void Update() override
Updates this component.
Definition: AnimationRenderComponent.cpp:48
unsigned int frameDifference
The x-axis distance between each frame of the animation.
Definition: AnimationRenderComponent.hpp:28