summaryrefslogtreecommitdiff
path: root/src/helpers/math/Direction.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers/math/Direction.hpp')
-rw-r--r--src/helpers/math/Direction.hpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/helpers/math/Direction.hpp b/src/helpers/math/Direction.hpp
new file mode 100644
index 00000000..9905db4f
--- /dev/null
+++ b/src/helpers/math/Direction.hpp
@@ -0,0 +1,35 @@
+#pragma once
+
+#include <cstdint>
+
+namespace Math {
+ enum eDirection : int8_t {
+ DIRECTION_DEFAULT = -1,
+ DIRECTION_UP,
+ DIRECTION_RIGHT,
+ DIRECTION_DOWN,
+ DIRECTION_LEFT
+ };
+
+ inline eDirection fromChar(char x) {
+ switch (x) {
+ case 'r': return DIRECTION_RIGHT;
+ case 'l': return DIRECTION_LEFT;
+ case 't':
+ case 'u': return DIRECTION_UP;
+ case 'b':
+ case 'd': return DIRECTION_DOWN;
+ default: return DIRECTION_DEFAULT;
+ }
+ }
+
+ inline const char* toString(eDirection d) {
+ switch (d) {
+ case DIRECTION_UP: return "up";
+ case DIRECTION_DOWN: return "down";
+ case DIRECTION_LEFT: return "left";
+ case DIRECTION_RIGHT: return "right";
+ default: return "default";
+ }
+ }
+}; \ No newline at end of file