From acf9e9f1eb880ffb8ab918c40724eda566aefcc7 Mon Sep 17 00:00:00 2001 From: nsensfel Date: Fri, 23 Feb 2018 11:35:45 +0100 Subject: Starting a big refactoring... --- src/struct/battlemap.erl | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/struct/battlemap.erl (limited to 'src/struct/battlemap.erl') diff --git a/src/struct/battlemap.erl b/src/struct/battlemap.erl new file mode 100644 index 0000000..f55aadb --- /dev/null +++ b/src/struct/battlemap.erl @@ -0,0 +1,60 @@ +-module(battlemap). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-record +( + battlemap, + { + id, + width, + height, + content, + instances + } +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +-export +( + [ + get_id/1, + get_width/1, + get_height/1, + list_tiles/1, + get_instances/1 + ] +). + +%%%% Utils +-export +( + [ + cross/5, + dist/2 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%% Accessors +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. + +%%%% Utils +-include("battlemap/cross_5.erl"). + +dist ({OX, OY}, {DX, DY}) -> + (abs(OX - DX) + abs(OY - DY)). -- cgit v1.2.3-70-g09d2