summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'client/elm/battlemap/src/Battlemap/Location.elm')
-rw-r--r--client/elm/battlemap/src/Battlemap/Location.elm18
1 files changed, 18 insertions, 0 deletions
diff --git a/client/elm/battlemap/src/Battlemap/Location.elm b/client/elm/battlemap/src/Battlemap/Location.elm
new file mode 100644
index 0000000..ffe3f0d
--- /dev/null
+++ b/client/elm/battlemap/src/Battlemap/Location.elm
@@ -0,0 +1,18 @@
+module Battlemap.Location exposing (..)
+
+import Battlemap.Direction exposing (..)
+
+type alias Location =
+ {
+ x : Int,
+ y : Int
+ }
+
+neighbor : Location -> Direction -> Location
+neighbor loc dir =
+ case dir of
+ Right -> {loc | x = (loc.x + 1)}
+ Left -> {loc | x = (loc.x - 1)}
+ Up -> {loc | y = (loc.y - 1)}
+ Down -> {loc | y = (loc.y + 1)}
+ None -> loc