This repository has been archived by the owner on May 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Actor.h
42 lines (37 loc) · 1.21 KB
/
Actor.h
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
#pragma once
#include <unordered_map>
class Animation;
class Timer;
class Frame;
#include <string>
#include <vector>
const std::string NULLString = "NULL";
class Actor
{
protected:
std::vector<Animation *> m_animations;
Animation* m_current_animation;
std::string m_current_animation_name;
bool m_has_animation_end;
unsigned int m_current_frame_index;
Timer* m_frame_timer;
float m_time_per_frame_seconds;
// Maps a state to an index in the animations array eg. m_animation_name_to_index["idle"] = 0
std::unordered_map<std::string, unsigned int> m_animation_name_to_index;
private:
void resetAnimationConstants(const std::string & animation_name);
public:
Actor(const std::vector<std::string>& animation_names,
const std::vector<std::string>& animation_directories,
const std::vector<unsigned int>& frames_per_animation,
float animation_speed_FPS);
virtual ~Actor();
bool playAnimation(const std::string& animation_name);
// Accumulates time into timer, Advances frame index by 1
void updateAnimationTimer(float dt);
void updateCurrentFrameIndex();
const std::string& getCurrentAnimationName();
unsigned int getCurrentFrameIndex();
bool animationFinished();
const std::string& getCurrentFrame();
};