aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/engine.hpp2
-rw-r--r--include/player.hpp32
2 files changed, 33 insertions, 1 deletions
diff --git a/include/engine.hpp b/include/engine.hpp
index e564691..d4b1e34 100644
--- a/include/engine.hpp
+++ b/include/engine.hpp
@@ -51,7 +51,7 @@ namespace game {
inline void endGame(void) {
events.emit<GameEndEvent>();
}
-
+
extern SpriteLoader sprite_l;
}
diff --git a/include/player.hpp b/include/player.hpp
new file mode 100644
index 0000000..430173f
--- /dev/null
+++ b/include/player.hpp
@@ -0,0 +1,32 @@
+#ifndef PLAYER_HPP_
+#define PLAYER_HPP_
+
+#include <entityx/entityx.h>
+
+#include <events.hpp>
+
+class PlayerSystem : public entityx::System<PlayerSystem>, public entityx::Receiver<PlayerSystem> {
+private:
+ entityx::Entity::Id pid;
+
+ bool moveLeft;
+ bool moveRight;
+
+ float speed;
+
+public:
+ PlayerSystem(void)
+ : moveLeft(false), moveRight(false), speed(1.0f) {}
+
+ void configure(entityx::EventManager&);
+
+ void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override;
+
+ void receive(const KeyUpEvent&);
+ void receive(const KeyDownEvent&);
+
+ inline void setPlayer(const entityx::Entity& e)
+ { pid = e.id(); }
+};
+
+#endif // PLAYER_HPP_