summaryrefslogtreecommitdiff
path: root/core/src/cpp/sprite.h
diff options
context:
space:
mode:
authorNikita Kostovsky <nikita@kostovsky.me>2025-12-23 15:28:05 +0100
committerNikita Kostovsky <nikita@kostovsky.me>2025-12-23 15:28:05 +0100
commitc055eeef6d41269d11b2ddf7f9aba6f8867da65d (patch)
treedcd9baaec93c50a8ab49656be86ea248c17421fd /core/src/cpp/sprite.h
initial commitHEADmaster
Diffstat (limited to 'core/src/cpp/sprite.h')
-rw-r--r--core/src/cpp/sprite.h48
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};
+};