From c055eeef6d41269d11b2ddf7f9aba6f8867da65d Mon Sep 17 00:00:00 2001 From: Nikita Kostovsky Date: Tue, 23 Dec 2025 15:28:05 +0100 Subject: initial commit --- core/src/cpp/sprite.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 core/src/cpp/sprite.h (limited to 'core/src/cpp/sprite.h') 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 +#include + +#include + +using Clock = std::chrono::high_resolution_clock; +using TimeStamp = std::chrono::time_point; + +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}; +}; -- cgit v1.2.3-70-g09d2