aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2017-01-19 20:55:39 -0500
committerClyne Sullivan <tullivan99@gmail.com>2017-01-19 20:55:39 -0500
commitdf22618e71ceeb73d3f4c6b8f74d9c07fce3ccea (patch)
tree7ad0c2d335fec50d1ccd9624effea317e847cebd /include
parent59edd60ebec61bf24dd27063f85bcd049fd0af13 (diff)
inventory item dragging
Diffstat (limited to 'include')
-rw-r--r--include/events.hpp8
-rw-r--r--include/inventory.hpp1
-rw-r--r--include/vector2.hpp8
3 files changed, 17 insertions, 0 deletions
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<T>& v) const {
+ return (x > v.x) && (y > v.y);
+ }
+
+ bool operator<(const vector2<T>& 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) + ")";