blob: d74ca75a33d7b80ab033aa5278f02cc12c3b9812 (
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
|
#pragma once
#include "sprite.h"
struct Animation : public Sprite
{
explicit Animation(
SDL_Renderer* renderer,
const std::string& filename,
const int width,
const double durationS,
const bool repeat
);
~Animation() override = default;
public:
/*!
* \brief animation_ended - is the animation sequence ended as specified
* timestamp?
* \param timestamp
* \return true if ended, false otherwise
*/
bool animation_ended(const TimeStamp timestamp) const;
/*!
* \brief frame - compute the frame number at current time for the the
* animation started at timestamp
* \param timestamp
* \return frame number
*/
int frame(const TimeStamp timestamp) const;
/*!
* \brief rect - choose the right frame from the texture
* \param timestamp
* \return frame rect
*/
SDL_Rect rect(const TimeStamp timestamp) const;
/*!
* \brief durationS - durationS of the animation sequence in seconds
*/
const double durationS{1.};
const bool repeat{false}; // should we repeat the animation?
};
|