From df22618e71ceeb73d3f4c6b8f74d9c07fce3ccea Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Thu, 19 Jan 2017 20:55:39 -0500 Subject: inventory item dragging --- include/events.hpp | 8 ++++++++ include/inventory.hpp | 1 + include/vector2.hpp | 8 ++++++++ 3 files changed, 17 insertions(+) (limited to 'include') diff --git a/include/events.hpp b/include/events.hpp index 5939c3d..6251fac 100644 --- a/include/events.hpp +++ b/include/events.hpp @@ -40,6 +40,14 @@ struct MouseClickEvent { int button; }; +struct MouseReleaseEvent { + MouseReleaseEvent(vec2 pos, int b) + : position(pos), button(b) {} + + vec2 position; + int button; +}; + struct KeyDownEvent { KeyDownEvent(SDL_Keycode kc = 0) : keycode(kc) {} diff --git a/include/inventory.hpp b/include/inventory.hpp index 2e261ae..084a2d6 100644 --- a/include/inventory.hpp +++ b/include/inventory.hpp @@ -86,6 +86,7 @@ public: void update(entityx::EntityManager &en, entityx::EventManager &ev, entityx::TimeDelta dt) override; void receive(const KeyDownEvent &kde); void receive(const MouseClickEvent &mce); + void receive(const MouseReleaseEvent &mce); void render(void); diff --git a/include/vector2.hpp b/include/vector2.hpp index 17e47d1..d335a4b 100644 --- a/include/vector2.hpp +++ b/include/vector2.hpp @@ -71,6 +71,14 @@ struct vector2 { return (x == v.x) && (y == v.y); } + bool operator>(const vector2& v) const { + return (x > v.x) && (y > v.y); + } + + bool operator<(const vector2& v) const { + return (x < v.x) && (y < v.y); + } + // other functions std::string toString(void) const { return "(" + std::to_string(x) + ", " + std::to_string(y) + ")"; -- cgit v1.2.3