From 816bedbd011b6729e8be0a4b40213f48fd9d73ca Mon Sep 17 00:00:00 2001 From: Clyne Sullivan <tullivan99@gmail.com> Date: Thu, 27 Oct 2016 20:50:29 -0400 Subject: names, jumping --- include/common.hpp | 6 ++++++ include/components.hpp | 6 ++++++ include/events.hpp | 2 +- include/player.hpp | 3 +++ include/world.hpp | 2 +- 5 files changed, 17 insertions(+), 2 deletions(-) (limited to 'include') 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 -- cgit v1.2.3