blob: 8c6006033f9951c2e21681f86094410755b52571 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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};
};
|