aboutsummaryrefslogtreecommitdiff
path: root/src/engine/data/vector2.hpp
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-03-07 20:20:18 +0100
committerHampusM <hampus@hampusmat.com>2022-06-13 17:56:55 +0200
commitf0824fdebc79fbf3843c2053522107c33e3ce2a3 (patch)
treee5bd34fa89cbe80cf8a30596766cf95098465aec /src/engine/data/vector2.hpp
parent12fffa7df0685ef6d23ffe888a06695ae490df81 (diff)
refactor: move directions to vector2 & make vector2 hashable
Diffstat (limited to 'src/engine/data/vector2.hpp')
-rw-r--r--src/engine/data/vector2.hpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/engine/data/vector2.hpp b/src/engine/data/vector2.hpp
index acfe11f..dff548c 100644
--- a/src/engine/data/vector2.hpp
+++ b/src/engine/data/vector2.hpp
@@ -1,6 +1,7 @@
#pragma once
#include <cstdint>
+#include <functional>
struct Vector2Options
{
@@ -27,7 +28,35 @@ public:
const Vector2 &operator+=(const Vector2 &vector2) noexcept;
const Vector2 &operator-=(const Vector2 &vector2) noexcept;
+ bool operator==(const Vector2 &vector2) const noexcept;
+
+ /**
+ * Returns Vector2({.x = 0, .y = 1})
+ */
+ static Vector2 up();
+
+ /**
+ * Returns Vector2({.x = 0, .y = -1})
+ */
+ static Vector2 down();
+
+ /**
+ * Returns Vector2({.x = -1, .y = 0})
+ */
+ static Vector2 left();
+
+ /**
+ * Returns Vector2({.x = 1, .y = 0})
+ */
+ static Vector2 right();
+
private:
int32_t _x;
int32_t _y;
};
+
+class Vector2Hasher
+{
+public:
+ std::size_t operator()(const Vector2 &vector2) const;
+};