From 9a2d8f37dea8e14afa57affb135def13954df547 Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Fri, 15 Sep 2017 09:52:54 +0200 Subject: Satisfied with Elm so far, let's go with it. --- client/elm/battlemap/src/Battlemap/Location.elm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 client/elm/battlemap/src/Battlemap/Location.elm (limited to 'client/elm/battlemap/src/Battlemap/Location.elm') 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 -- cgit v1.2.3-70-g09d2