#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 */