diff options
Diffstat (limited to 'core/src/cpp/sprite.h')
| -rw-r--r-- | core/src/cpp/sprite.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/core/src/cpp/sprite.h b/core/src/cpp/sprite.h new file mode 100644 index 0000000..8c60060 --- /dev/null +++ b/core/src/cpp/sprite.h @@ -0,0 +1,48 @@ +#pragma once + +#include <chrono> +#include <string> + +#include <SDL_rect.h> + +using Clock = std::chrono::high_resolution_clock; +using TimeStamp = std::chrono::time_point<Clock>; + +struct SDL_Texture; +struct SDL_Renderer; + +struct Sprite { + explicit Sprite( + SDL_Renderer* renderer, + const std::string& filename, + const int width + ); + + virtual ~Sprite(); + +public: + /*! + * \brief rect - choose the sprite rect from the texture by index + * \param idx - index of sprite + * \return + */ + SDL_Rect rect(const int idx) const; + +public: + /*! + * \brief texture - the image is to be stored here + */ + SDL_Texture* texture{nullptr}; + /*! + * \brief width - single sprite width (texture width = width * nframes) + */ + int width{0}; + /*! + * \brief height - sprite height + */ + int height{0}; + /*! + * \brief nframes - number of frames in the animation sequence + */ + int nframes{0}; +}; |
