summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2017-11-28 17:14:02 +0100
committernsensfel <SpamShield0@noot-noot.org>2017-11-28 17:14:02 +0100
commitf539b7072c357339328d9bfd54f1f1ed51828586 (patch)
treeb6205dd79c78090831e812aceac177d2a9f35d28 /src/type/battlemap.erl
parent80358376b9300a0d73cb8b62dfa9fdd65240ca66 (diff)
Trying to tidy up this mess.
Diffstat (limited to 'src/type/battlemap.erl')
-rw-r--r--src/type/battlemap.erl38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/type/battlemap.erl b/src/type/battlemap.erl
new file mode 100644
index 0000000..cce1a76
--- /dev/null
+++ b/src/type/battlemap.erl
@@ -0,0 +1,38 @@
+-module(battlemap).
+-record
+(
+ battlemap,
+ {
+ id,
+ width,
+ height,
+ content,
+ instances
+ }
+).
+-export
+(
+ [
+ get_id/1,
+ get_width/1,
+ get_height/1,
+ list_tiles/1,
+ get_instances/1
+ ]
+).
+-export
+(
+ [dist/2]
+).
+-export([cross/5]).
+
+get_id (Battlemap) -> Battlemap#battlemap.id.
+get_width (Battlemap) -> Battlemap#battlemap.width.
+get_height (Battlemap) -> Battlemap#battlemap.height.
+list_tiles (Battlemap) -> array:sparse_to_list(Battlemap#battlemap.content).
+get_instances (Battlemap) -> Battlemap#battlemap.instances.
+
+-include("battlemap/cross.erl").
+
+dist ({OX, OY}, {DX, DY}) ->
+ (abs(OX - DX) + abs(OY + DY)).