-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlayerAnimations.h
More file actions
48 lines (36 loc) · 789 Bytes
/
PlayerAnimations.h
File metadata and controls
48 lines (36 loc) · 789 Bytes
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
#pragma once
#include "TextureId.h"
#include "AlarmClock.h"
#include <SFML/Graphics/Sprite.hpp>
class PlayerAnimations : public sf::Drawable
{
public:
enum class State : uint8_t
{
Idle,
Walk
};
enum class Direction : uint8_t
{
Right,
Left
};
PlayerAnimations(TextureId textureId, float frameSecs);
void update(float deltaTime);
void draw(sf::RenderTarget &target, sf::RenderStates states) const override;
void setState(State state);
void setDirection(Direction direction);
void setPosition(const sf::Vector2f &position);
private:
State state_;
Direction direction_;
sf::Sprite sprite_;
uint8_t frameWidth_;
uint8_t frameHeight_;
uint8_t numCols_;
uint8_t col_;
uint8_t row_;
AlarmClock frameClock_;
void updateRow_();
void updateFrameRect_();
};