diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-10-27 20:50:29 -0400 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-10-27 20:50:29 -0400 |
commit | 816bedbd011b6729e8be0a4b40213f48fd9d73ca (patch) | |
tree | b42d7dc277c415db4b826182ecd26b10b714697e /include | |
parent | 0fa2320e978926db6781a2bdcdf5a9b6f0317e93 (diff) |
names, jumping
Diffstat (limited to 'include')
-rw-r--r-- | include/common.hpp | 6 | ||||
-rw-r--r-- | include/components.hpp | 6 | ||||
-rw-r--r-- | include/events.hpp | 2 | ||||
-rw-r--r-- | include/player.hpp | 3 | ||||
-rw-r--r-- | include/world.hpp | 2 |
5 files changed, 17 insertions, 2 deletions
diff --git a/include/common.hpp b/include/common.hpp index d152bb7..d13e397 100644 --- a/include/common.hpp +++ b/include/common.hpp @@ -58,6 +58,12 @@ typedef unsigned int uint; #define BREAKPOINT __asm__("int $3") +template<typename T> +inline const T * const& coalesce(const T * const &p1, const T * const &p2) +{ + return ((p1 == nullptr) ? p2 : p1); +} + /** * Creates a coordinate of integers. */ diff --git a/include/components.hpp b/include/components.hpp index c0b7110..1195337 100644 --- a/include/components.hpp +++ b/include/components.hpp @@ -81,6 +81,12 @@ struct Portal { std::string toFile; }; +struct Name { + Name(std::string n = "") : name(n) {} + + std::string name; +}; + /** * @struct Solid * @brief Allows an entity to collide with other objects. diff --git a/include/events.hpp b/include/events.hpp index d98d52a..6a9bd8c 100644 --- a/include/events.hpp +++ b/include/events.hpp @@ -16,7 +16,7 @@ struct MouseScrollEvent { : scrollDistance(sd) {} int scrollDistance; - }; +}; struct KeyDownEvent { KeyDownEvent(SDL_Keycode kc = 0) diff --git a/include/player.hpp b/include/player.hpp index e196fa4..187e77e 100644 --- a/include/player.hpp +++ b/include/player.hpp @@ -4,6 +4,7 @@ #include <entityx/entityx.h> #include <events.hpp> +#include <components.hpp> #include <common.hpp> constexpr const float PLAYER_SPEED_CONSTANT = 0.15f; @@ -31,6 +32,8 @@ public: void receive(const KeyDownEvent&); vec2 getPosition(void) const; + inline void setX(const float& x) + { player.component<Position>().get()->x = x; } }; #endif // PLAYER_HPP_ diff --git a/include/world.hpp b/include/world.hpp index fb0a5fa..421031c 100644 --- a/include/world.hpp +++ b/include/world.hpp @@ -166,7 +166,7 @@ public: void detect(entityx::TimeDelta dt); void goWorldLeft(Position& p); - void goWorldRight(Position& p); + void goWorldRight(Position& p, Solid &d); void goWorldPortal(Position& p); // worlddata2 stuff |