2012-10-14 16:14:06 +00:00
|
|
|
/*
|
|
|
|
* Player.h
|
|
|
|
*
|
|
|
|
* Created on: 21.07.2012
|
|
|
|
* Author: Felix
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef DG_PLAYER_H_
|
|
|
|
#define DG_PLAYER_H_
|
|
|
|
|
|
|
|
#include <SFML/System.hpp>
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
|
|
|
|
#include "../abstract/Character.h"
|
|
|
|
#include "../items/Weapon.h"
|
|
|
|
#include "../util/Pathfinder.h"
|
|
|
|
#include "../util/Yaml.h"
|
|
|
|
|
|
|
|
class Character;
|
|
|
|
class Instances;
|
|
|
|
class Pathfinder;
|
|
|
|
class Weapon;
|
|
|
|
class Yaml;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Player object.
|
|
|
|
*/
|
|
|
|
class Player : public Character {
|
|
|
|
// Public types.
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Movement directions that can be set via Player::setDirection().
|
|
|
|
*/
|
2012-12-22 00:14:30 +00:00
|
|
|
enum Direction : unsigned char {
|
2012-10-14 16:14:06 +00:00
|
|
|
RIGHT = 1 << 0,
|
|
|
|
LEFT = 1 << 1,
|
|
|
|
UP = 1 << 2,
|
|
|
|
DOWN = 1 << 3
|
|
|
|
};
|
|
|
|
|
|
|
|
// Public functions.
|
2012-09-12 12:21:57 +00:00
|
|
|
public:
|
2012-12-22 13:56:17 +00:00
|
|
|
Player(World& world, Pathfinder& pathfinder,
|
2012-12-22 14:10:26 +00:00
|
|
|
const sf::Vector2f& position, const Yaml& config);
|
2012-10-14 16:14:06 +00:00
|
|
|
|
2012-12-22 14:10:26 +00:00
|
|
|
void setCrosshairPosition(const sf::Vector2f& position);
|
2012-10-14 16:14:06 +00:00
|
|
|
void fire();
|
2012-12-22 14:10:26 +00:00
|
|
|
void move(const sf::Vector2f& destination);
|
2012-10-14 16:14:06 +00:00
|
|
|
void setDirection(Direction direction, bool unset);
|
|
|
|
|
|
|
|
// Private functions.
|
|
|
|
private:
|
2012-12-22 00:14:30 +00:00
|
|
|
void onCollide(Body& other, Category category);
|
2012-10-14 16:14:06 +00:00
|
|
|
void onThink(float elapsedTime);
|
|
|
|
|
|
|
|
// Private variables.
|
|
|
|
private:
|
2012-12-22 14:10:26 +00:00
|
|
|
sf::Vector2f mCrosshairPosition; //< Relative position of the point to fire at (mouse cursor).
|
2012-12-22 00:14:30 +00:00
|
|
|
unsigned char mDirection; //< Current movement direction for direct control.
|
2012-10-14 16:14:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* DG_PLAYER_H_ */
|