summaryrefslogtreecommitdiff
blob: 5c7bc486c7d19358c89f1fd1315d5166bfcefb0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module Battlemap.Location exposing (..)

import Battlemap.Direction exposing (Direction(..))

type alias Location =
   {
      x : Int,
      y : Int
   }

type alias LocationRef = (Int, 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

to_comparable : Location -> (Int, Int)
to_comparable l =
   (l.x, l.y)