-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnimation.hpp
56 lines (52 loc) · 1.26 KB
/
Animation.hpp
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
49
50
51
52
53
54
55
56
/**
* @file Animation.hpp
* @brief Plays animations on the screen.
* @author Josh Kennedy
*
* Kablam!
* Copyright (C) 2024 Josh Kennedy.
*/
#pragma once
enum class AnimationType : char
{
HORIZONTAL_SPRITE_STRIP = 0,
};
struct SDL_Texture;
struct SDL_Renderer;
class Animation
{
private:
SDL_Texture* texture; // don't free this
int numFrames;
int currentFrame;
int frameWidth;
int frameHeight;
int framesPerSecond;
AnimationType type;
int x;
int y;
bool loop;
bool isActive;
double timeSinceLastFrame;
int xOffSet;
int yOffSet;
public:
Animation();
Animation(SDL_Texture* texture, int numFrames, int frameWidth, int frameHeight, int framesPerSecond, bool loop = true, int xOffSet = 0, int yOffSet = 0);
void update(double delta);
void render(SDL_Renderer* renderer);
inline int getX() const { return x; }
inline void setX(int x) { this->x = x; }
inline int getY() const { return y; }
inline void setY(int y) { this->y = y; }
int getCurrentFrame() const;
int getNumFrames() const;
int getFrameWidth() const;
int getFrameHeight() const;
void play();
void pause();
void stop();
bool isPlaying() const;
void setLoop(bool loop);
bool isLooping() const;
};