You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
735 B
C
38 lines
735 B
C
4 years ago
|
#ifndef PLAYER_H
|
||
|
#define PLAYER_H
|
||
|
|
||
|
#include <queue>
|
||
|
#include <map>
|
||
|
#include <SFML/Window/Event.hpp>
|
||
|
|
||
|
class Command;
|
||
|
|
||
|
class Player
|
||
|
{
|
||
|
public:
|
||
|
Player();
|
||
|
|
||
|
enum class Action
|
||
|
{
|
||
|
MoveLeft,
|
||
|
MoveRight,
|
||
|
MoveUp,
|
||
|
MoveDown
|
||
|
};
|
||
|
|
||
|
void assignKey(Action action, sf::Keyboard::Key key);
|
||
|
sf::Keyboard::Key getAssignedKey(Action action) const;
|
||
|
|
||
|
void handleEvent(const sf::Event& event, std::queue<Command>& queue);
|
||
|
void handleRealtimeInput(std::queue<Command>& queue);
|
||
|
|
||
|
private:
|
||
|
float player_speed;
|
||
|
std::map<sf::Keyboard::Key, Action> map_key_bindings;
|
||
|
std::map<Action, Command> map_action_bindings;
|
||
|
|
||
|
static bool isRealtime(Action action) {return true;}
|
||
|
};
|
||
|
|
||
|
#endif // PLAYER_H
|