-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.h
46 lines (34 loc) · 757 Bytes
/
Player.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
43
44
45
46
#pragma once
#include "Collidable.h"
#include "Listener.h"
#include "PlayerAnimations.h"
#include <SFML/Window/Keyboard.hpp>
class Player :
public Collidable,
public Listener,
public sf::Drawable
{
public:
Player(uint8_t health);
void onEvent(const Event &ev) override;
void update(float deltaTime);
void updateOnKeyPress(sf::Keyboard::Key key);
void updateOnKeyRelease(sf::Keyboard::Key key);
void constrain(const Boundable &bounds);
void draw(sf::RenderTarget &target, sf::RenderStates states) const override;
bool isLive() const;
private:
enum MoveFlag : uint8_t
{
None = 0,
Up = 1,
Down = 2,
Left = 4,
Right = 8
};
uint8_t moveFlags_;
PlayerAnimations animations_;
uint8_t health_;
float speed_;
void hurt_();
};