blob: 4f70e49e69eacc3220e3576f1157c17cdc3ac3ad (
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
type alias Type =
{
x : Int,
y : Int
}
type alias Ref = (Int, Int)
neighbor : Type -> Battlemap.Direction.Type -> Type
neighbor loc dir =
case dir of
Battlemap.Direction.Right -> {loc | x = (loc.x + 1)}
Battlemap.Direction.Left -> {loc | x = (loc.x - 1)}
Battlemap.Direction.Up -> {loc | y = (loc.y - 1)}
Battlemap.Direction.Down -> {loc | y = (loc.y + 1)}
Battlemap.Direction.None -> loc
get_ref : Type -> Ref
get_ref l =
(l.x, l.y)
|