diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-12-17 20:13:43 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-12-17 20:13:43 -0500 |
commit | fa802f8fbc62910b37002bcdd2f7c110f488e392 (patch) | |
tree | 28b0897d6af8879f7249189ea69c78e458ed2c0d /include/player.hpp | |
parent | b6141f6cbf07f0fbfadc892488f2ba83b7cf1719 (diff) |
ui cleaning, docs
Diffstat (limited to 'include/player.hpp')
-rw-r--r-- | include/player.hpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/include/player.hpp b/include/player.hpp index 59d6368..85dc821 100644 --- a/include/player.hpp +++ b/include/player.hpp @@ -1,3 +1,8 @@ +/** + * @file player.hpp + * @brief The player system + */ + #ifndef PLAYER_HPP_ #define PLAYER_HPP_ @@ -8,8 +13,15 @@ #include <components.hpp> #include <common.hpp> +/** + * The constant velocity the player is given when moved with the arrow keys. + */ constexpr const float PLAYER_SPEED_CONSTANT = 0.15f; +/** + * @class PlayerSystem + * Controls a player, with keyboard and stuff. + */ class PlayerSystem : public entityx::System<PlayerSystem>, public entityx::Receiver<PlayerSystem> { private: entityx::Entity player; @@ -23,18 +35,50 @@ public: PlayerSystem(void) : moveLeft(false), moveRight(false), speed(1.0f) {} + /** + * Creates the player, adding it to the entity system. + */ void create(void); + /** + * Configures events for use with the entity system. + */ void configure(entityx::EventManager&); + /** + * Updates the player, mainly the player's velocity. + */ void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override; + /** + * Handles key up events for the player. + * @param kue key up event data + */ void receive(const KeyUpEvent&); + + /** + * Handles key down events for the player. + * @param kde key down event data + */ void receive(const KeyDownEvent&); + /** + * Gets the player's position. + * @return the player's position + */ vec2 getPosition(void) const; + + /** + * Sets the player's X coordinate. + * @param x the x coordinate to give the player + */ inline void setX(const float& x) { player.component<Position>().get()->x = x; } + + /** + * Gets the width of the player. + * @return the player's width, according to its sprite + */ inline float getWidth(void) const { return game::entities.component<Solid>(player.id())->width; } }; |