summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2018-10-11 17:49:47 +0200
committernsensfel <SpamShield0@noot-noot.org>2018-10-11 17:49:47 +0200
commitaea6e1872eeccffdef926b6561767ff59aecf87e (patch)
tree78b8848ccfa8d6002075bfe738ac0d66682e8add /src/map
parent4182b46e67185e1f024a24e7cba0d82e24f29baa (diff)
(Broken) 'spe' to add new map to player.
Diffstat (limited to 'src/map')
-rw-r--r--src/map/map_shim.erl8
-rw-r--r--src/map/struct/map_map.erl34
2 files changed, 28 insertions, 14 deletions
diff --git a/src/map/map_shim.erl b/src/map/map_shim.erl
index a7f00cc..600af60 100644
--- a/src/map/map_shim.erl
+++ b/src/map/map_shim.erl
@@ -7,7 +7,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--export([generate_random_map/2]).
+-export([generate_random_map/1]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -52,8 +52,8 @@ demo_map () ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--spec generate_random_map (non_neg_integer(), binary()) -> map_map:type().
-generate_random_map (ID, Owner) ->
- Map = map_map:from_list(ID, Owner, 32, 32, demo_map()),
+-spec generate_random_map (binary()) -> map_map:type().
+generate_random_map (Owner) ->
+ Map = map_map:from_list(Owner, 32, 32, demo_map()),
Map.
diff --git a/src/map/struct/map_map.erl b/src/map/struct/map_map.erl
index 55c1a41..0e9474b 100644
--- a/src/map/struct/map_map.erl
+++ b/src/map/struct/map_map.erl
@@ -9,7 +9,6 @@
(
map,
{
- id :: id(),
owner :: binary(),
width :: integer(),
height :: integer(),
@@ -28,7 +27,6 @@
-export
(
[
- get_id/1,
get_owner/1,
get_width/1,
get_height/1,
@@ -49,8 +47,9 @@
-export
(
[
- from_list/5,
- update_from_list/4
+ from_list/4,
+ update_from_list/4,
+ default/1
]
).
@@ -75,9 +74,6 @@ location_to_array_index (ArrayWidth, {X, Y}) ->
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Accessors
--spec get_id (type()) -> id().
-get_id (Map) -> Map#map.id.
-
-spec get_owner (type()) -> binary().
get_owner (Map) -> Map#map.owner.
@@ -106,19 +102,17 @@ get_tile_instances_field () -> #map.tile_instances.
-spec from_list
(
- non_neg_integer(),
binary(),
non_neg_integer(),
non_neg_integer(),
list(list(non_neg_integer()))
)
-> type().
-from_list (ID, Owner, Width, Height, List) ->
+from_list (Owner, Width, Height, List) ->
TileInstances = lists:map(fun shr_tile:instance_from_ints/1, List),
#map
{
- id = list_to_binary(integer_to_list(ID)),
owner = Owner,
width = Width,
height = Height,
@@ -142,3 +136,23 @@ update_from_list (Map, Width, Height, List) ->
height = Height,
tile_instances = array:from_list(TileInstances)
}.
+
+-spec default (binary()) -> type().
+default (Owner) ->
+ DefaultTileInstance = shr_tile:default_tile_instance(),
+
+ #map
+ {
+ owner = Owner,
+ width = 32,
+ height = 32,
+ tile_instances =
+ array:new
+ (
+ [
+ {size, 1024},
+ {default, DefaultTileInstance},
+ {fixed, true}
+ ]
+ )
+ }.