summaryrefslogtreecommitdiff
blob: 2fa6d5deaeeb107339fdc03d2dbca1c028d6e58d (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 (..)

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

type alias LocationComparable = (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)