blob: f1eddb6f9b0fdc56864953b82f00803dbb02528b (
plain) (
blame)
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
|
#ifndef ANIMATION_H_332518EB
#define ANIMATION_H_332518EB
#include <string>
#include <map>
#include <vector>
#include <string_view>
#include <SDL.h>
#include "direction.h"
#include "timer.h"
class Animation {
public:
explicit Animation(std::string_view path);
void setDirection(Direction dir);
void setAnimation(std::string_view anim);
const SDL_Rect& getRenderRect() const {
return frames_.at(animations_.at(animationId_).at(animationFrame_));
}
Direction getDirection() const { return dir_; }
void update(int dt);
private:
void updateAnim();
std::vector<SDL_Rect> frames_;
std::vector<std::vector<int>> animations_;
std::map<std::string, std::map<Direction, int>> nameDirToAnim_;
Direction dir_ = Direction::down;
std::string animationName_ = "still";
int animationId_ = 0;
int animationFrame_ = 0;
Timer animTimer_ = {1000/5};
};
#endif /* end of include guard: ANIMATION_H_332518EB */
|