summaryrefslogtreecommitdiff |
diff options
Diffstat (limited to 'src/shim/battlemap_shim.erl')
-rw-r--r-- | src/shim/battlemap_shim.erl | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/shim/battlemap_shim.erl b/src/shim/battlemap_shim.erl new file mode 100644 index 0000000..b19a653 --- /dev/null +++ b/src/shim/battlemap_shim.erl @@ -0,0 +1,64 @@ +-module(battlemap_shim). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-record +( + battlemap, + { + id, + width, + height, + content, + instances + } +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export +( + [ + generate_random/0 + ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +generate(_Prev, Result, _X, 0, _BaseWidth) -> + Result; +generate(Prev, Result, 0, Y, BaseWidth) -> + generate(Prev, Result, BaseWidth, (Y - 1), BaseWidth); +generate(Prev, Result, X, Y, BaseWidth) -> + case rand:uniform(100) of + N when (N >= 10) -> + generate(Prev, [Prev|Result], (X - 1), Y, BaseWidth); + + N -> + NewTileType = (N - 1), + generate + ( + NewTileType, + [NewTileType|Result], + (X - 1), + Y, + BaseWidth + ) + end. + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +generate_random () -> + Width = (rand:uniform(48) + 16), + Height = (rand:uniform(48) + 16), + #battlemap + { + id = <<"0">>, + width = Width, + height = Height, + content = array:from_list(generate(0, [], Width, Height, Width)) + }. |