-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.hpp
48 lines (38 loc) · 1.16 KB
/
Player.hpp
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
#ifndef SFML_TEMPLATE_PLAYER_HPP
#define SFML_TEMPLATE_PLAYER_HPP
#include <SFML/Window/Event.hpp>
#include <map>
#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/Drawable.hpp>
#include "system/Command.hpp"
class CommandQueue;
class Player : public sf::Drawable {
public:
enum Action {
MOVE_LEFT,
MOVE_RIGHT,
DUPLICATE_BALL,
SLOWDOWN_BALL
};
Player();
void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
void handleEvent(const sf::Event& event, CommandQueue& commands);
void handleRealtimeInput(CommandQueue& commands);
void assignKey(Action action, sf::Keyboard::Key key);
sf::Keyboard::Key getAssignedKey(Action action) const;
void setScore(int score);
int getScore() const;
void setLevel(int level);
int getLevel() const;
private:
void initializeActions();
static bool isRealtimeAction(Action action);
std::map<sf::Keyboard::Key, Action> keyBinding;
std::map<Action, Command> actionBinding;
int score{0};
int level{0};
bool mouseDrag{false};
sf::Vector2f dragStart;
sf::Vector2f dragEnd;
};
#endif //SFML_TEMPLATE_PLAYER_HPP