summaryrefslogtreecommitdiff
path: root/dir.go
diff options
context:
space:
mode:
Diffstat (limited to 'dir.go')
-rw-r--r--dir.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/dir.go b/dir.go
new file mode 100644
index 0000000..693db98
--- /dev/null
+++ b/dir.go
@@ -0,0 +1,23 @@
+package mt
+
+// A Dir represents a direction parallel to an axis.
+type Dir uint8
+
+const (
+ East Dir = iota // +X
+ Above // +Y
+ North // +Z
+ South // -Z
+ Below // -Y
+ West // -X
+ NoDir
+)
+
+// Opposite returns the Dir's opposite.
+// NoDir is its own opposite.
+func (d Dir) Opposite() Dir {
+ if d >= NoDir {
+ return NoDir
+ }
+ return 5 - d
+}