diff options
author | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-08 11:44:21 +0100 |
---|---|---|
committer | heavydemon21 <nielsstunnebrink1@gmail.com> | 2024-11-08 11:44:21 +0100 |
commit | 9432900158e6a31815345fcf0af8d28ae34c6da9 (patch) | |
tree | 36f799da46ba8f5e921349d0f004b08d6d2f29ea /src/crepe/api/Animator.h | |
parent | 1c4156ee127b14760ed3b1a0cd16ad12180c7ac6 (diff) |
code style
Diffstat (limited to 'src/crepe/api/Animator.h')
-rw-r--r-- | src/crepe/api/Animator.h | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/crepe/api/Animator.h b/src/crepe/api/Animator.h new file mode 100644 index 0000000..3493623 --- /dev/null +++ b/src/crepe/api/Animator.h @@ -0,0 +1,87 @@ +#pragma once + +#include "Component.h" +#include "api/Sprite.h" +#include <cstdint> + +namespace crepe { +class AnimatorSystem; +class SDLContext; + + +/** + * \brief The Animator component is used to animate sprites by managing the movement + * and frame changes within a sprite sheet. + * + * This component allows for controlling sprite animation through rows and columns of a sprite sheet. + * It can be used to play animations, loop them, or stop them. + */ +class Animator : public Component { + +public: + //TODO: need to implement this + void loop(); + void stop(); + +public: + /** + * \brief Constructs an Animator object that will control animations for a sprite sheet. + * + * \param[in] id The unique identifier for the component, typically assigned automatically. + * \param[in] spritesheet A reference to the Sprite object which holds the sprite sheet for animation. + * \param[in] row The maximum number of rows in the sprite sheet. + * \param[in] col The maximum number of columns in the sprite sheet. + * \param[in] col__animate The specific col index of the sprite sheet to animate. This allows selecting which col to animate from multiple col in the sheet. + * + * This constructor sets up the Animator with the given parameters, and initializes the animation system. + */ + Animator(uint32_t id, Sprite & spritesheet, int row, int col, + int col_animate); + + /** + * \brief Destroys the Animator object and cleans up any resources. + * + * This destructor will handle any necessary cleanup when the Animator component is no longer needed. + */ + ~Animator(); + + //! Deleted copy constructor to prevent copying of the Animator instance. + Animator(const Animator &) = delete; + + //! Deleted move constructor to prevent moving of the Animator instance. + Animator(Animator &&) = delete; + + //! Deleted copy assignment operator to prevent copying the Animator instance. + Animator & operator=(const Animator &) = delete; + + //! Deleted move assignment operator to prevent moving the Animator instance. + Animator & operator=(Animator &&) = delete; + +private: + //! A reference to the Sprite sheet containing the animation frames. + Sprite & spritesheet; + + //! The maximum number of columns in the sprite sheet. + const int col; + + //! The maximum number of rows in the sprite sheet. + const int row; + + //! The current col being animated. + int curr_col = 0; + + //! The current row being animated. + int curr_row = 0; + + Rect animator_rect; + + //TODO: Is this necessary? + //int fps; + +private: + //! Friend class that can directly access the private members of the Animator. + friend class AnimatorSystem; + friend class SDLContext; +}; +} // namespace crepe +// |