summaryrefslogtreecommitdiff |
diff options
author | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2017-09-22 22:09:26 +0200 |
---|---|---|
committer | Nathanael Sensfelder <SpamShield0@MultiAgentSystems.org> | 2017-09-22 22:09:26 +0200 |
commit | dbad54ad228df4b70f56bf6be1380b6ae3064ac3 (patch) | |
tree | d912846d4948ebdee175ce3b6a7b97048e5995ce /client/elm/battlemap/src/Battlemap/Location.elm | |
parent | 5345adad33566e39570f067e61780e1af2dae4a7 (diff) |
First shot at range indicators.
Diffstat (limited to 'client/elm/battlemap/src/Battlemap/Location.elm')
-rw-r--r-- | client/elm/battlemap/src/Battlemap/Location.elm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/client/elm/battlemap/src/Battlemap/Location.elm b/client/elm/battlemap/src/Battlemap/Location.elm index 4f70e49..36f0c4d 100644 --- a/client/elm/battlemap/src/Battlemap/Location.elm +++ b/client/elm/battlemap/src/Battlemap/Location.elm @@ -22,3 +22,23 @@ neighbor loc dir = get_ref : Type -> Ref get_ref l = (l.x, l.y) + +from_ref : Ref -> Type +from_ref (x, y) = + {x = x, y = y} + +dist : Type -> Type -> Int +dist loc_a loc_b = + if (loc_a.x > loc_b.x) + then + if (loc_a.y > loc_b.y) + then + ((loc_a.x - loc_b.x) + (loc_a.y - loc_b.y)) + else + ((loc_a.x - loc_b.x) + (loc_b.y - loc_a.y)) + else + if (loc_a.y > loc_b.y) + then + ((loc_b.x - loc_a.x) + (loc_a.y - loc_b.y)) + else + ((loc_b.x - loc_a.x) + (loc_b.y - loc_a.y)) |