summary refs log tree commit diff stats
path: root/src/animation.h
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2022-03-12 12:09:58 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2022-03-12 12:09:58 -0500
commitbe9ccb73bc20b03f62c77f5d529602a10ef4eda9 (patch)
tree6f88a9b780a75e52b2f04b6f61167f4ef46590a7 /src/animation.h
parentc1a88a064a0cddbc1df2e716ef2102d22bbf681b (diff)
downloadether-be9ccb73bc20b03f62c77f5d529602a10ef4eda9.tar.gz
ether-be9ccb73bc20b03f62c77f5d529602a10ef4eda9.tar.bz2
ether-be9ccb73bc20b03f62c77f5d529602a10ef4eda9.zip
player has a sprite now thanks to world of solaria
Diffstat (limited to 'src/animation.h')
-rw-r--r--src/animation.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/animation.h b/src/animation.h new file mode 100644 index 0000000..0108c12 --- /dev/null +++ b/src/animation.h
@@ -0,0 +1,39 @@
1#ifndef ANIMATION_H_332518EB
2#define ANIMATION_H_332518EB
3
4#include <string>
5#include <map>
6#include <vector>
7#include <string_view>
8#include <SDL.h>
9#include "direction.h"
10#include "timer.h"
11
12class Animation {
13public:
14 explicit Animation(std::string_view path);
15
16 void setDirection(Direction dir);
17 void setAnimation(std::string_view anim);
18
19 const SDL_Rect& getRenderRect() const {
20 return frames_.at(animations_.at(animationId_).at(animationFrame_));
21 }
22
23 void update(int dt);
24
25private:
26
27 void updateAnim();
28
29 std::vector<SDL_Rect> frames_;
30 std::vector<std::vector<int>> animations_;
31 std::map<std::string, std::map<Direction, int>> nameDirToAnim_;
32 Direction dir_ = Direction::down;
33 std::string animationName_ = "still";
34 int animationId_ = 0;
35 int animationFrame_ = 0;
36 Timer animTimer_ = {1000/5};
37};
38
39#endif /* end of include guard: ANIMATION_H_332518EB */