Refactored lake generation and collision-restricted generation...
This commit is contained in:
parent
1699d73d55
commit
c59d915f66
@ -14,7 +14,6 @@ package body world is
|
|||||||
view_reach : constant integer := 96;
|
view_reach : constant integer := 96;
|
||||||
|
|
||||||
lake_count : constant natural := 3;
|
lake_count : constant natural := 3;
|
||||||
lake_reach : constant natural := 12;
|
|
||||||
|
|
||||||
landmark_limit : constant integer := 90;
|
landmark_limit : constant integer := 90;
|
||||||
location_limit : constant integer := 30;
|
location_limit : constant integer := 30;
|
||||||
@ -36,7 +35,24 @@ package body world is
|
|||||||
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
procedure earth_to_water_transition is
|
procedure generate_lake (x, y : in integer; size : in natural) is
|
||||||
|
starts, length : integer;
|
||||||
|
begin
|
||||||
|
for offset_x in -size / 2 .. size / 2 loop
|
||||||
|
starts := core.random (0, abs offset_x);
|
||||||
|
length := core.random (size / 2, size - starts);
|
||||||
|
--
|
||||||
|
for repeat in 0 .. 1 loop
|
||||||
|
for offset_y in starts .. starts + length loop
|
||||||
|
map.tiles (x + 2 * offset_x + repeat, y + offset_y) := core.random (18, 23);
|
||||||
|
end loop;
|
||||||
|
end loop;
|
||||||
|
end loop;
|
||||||
|
end generate_lake;
|
||||||
|
|
||||||
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
procedure compute_earth_to_water_transition is
|
||||||
matrix : array (0 .. 1, 0 .. 1) of natural;
|
matrix : array (0 .. 1, 0 .. 1) of natural;
|
||||||
begin
|
begin
|
||||||
for x in 1 .. map.width - 2 loop
|
for x in 1 .. map.width - 2 loop
|
||||||
@ -62,7 +78,7 @@ package body world is
|
|||||||
end if;
|
end if;
|
||||||
end loop;
|
end loop;
|
||||||
end loop;
|
end loop;
|
||||||
end earth_to_water_transition;
|
end compute_earth_to_water_transition;
|
||||||
|
|
||||||
------------------------------------------------------------------------------------------
|
------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -133,28 +149,12 @@ package body world is
|
|||||||
end loop;
|
end loop;
|
||||||
--
|
--
|
||||||
for this in 1 .. lake_count loop
|
for this in 1 .. lake_count loop
|
||||||
declare lake_x : integer := 0;
|
generate_lake (x => core.random (23, map.width - 23),
|
||||||
lake_y : integer := 0;
|
y => core.random (23, map.height - 23),
|
||||||
starts : integer := 0;
|
size => core.random (7, 19));
|
||||||
length : integer := 0;
|
|
||||||
begin
|
|
||||||
lake_x := core.random (2 * lake_reach, map.width - 2 * lake_reach - 1);
|
|
||||||
lake_y := core.random (2 * lake_reach, map.height - 2 * lake_reach - 1);
|
|
||||||
--
|
|
||||||
for x in -lake_reach / 2 .. lake_reach / 2 loop
|
|
||||||
starts := core.random (0, abs x);
|
|
||||||
length := core.random (lake_reach / 2, lake_reach - starts);
|
|
||||||
--
|
|
||||||
for repeat in 0 .. 1 loop
|
|
||||||
for y in starts .. starts + length loop
|
|
||||||
map.tiles (lake_x + 2 * x + repeat, lake_y + y) := core.random (18, 23);
|
|
||||||
end loop;
|
|
||||||
end loop;
|
|
||||||
end loop;
|
|
||||||
end;
|
|
||||||
end loop;
|
end loop;
|
||||||
--
|
--
|
||||||
earth_to_water_transition;
|
compute_earth_to_water_transition;
|
||||||
--
|
--
|
||||||
for x in 0 .. width - 1 loop
|
for x in 0 .. width - 1 loop
|
||||||
for y in 0 .. height - 1 loop
|
for y in 0 .. height - 1 loop
|
||||||
@ -167,9 +167,14 @@ package body world is
|
|||||||
for index in 1 .. landmark_limit loop
|
for index in 1 .. landmark_limit loop
|
||||||
map.landmarks (index).index := core.random (0, landmark_count - 1);
|
map.landmarks (index).index := core.random (0, landmark_count - 1);
|
||||||
map.landmarks (index).state := 0;
|
map.landmarks (index).state := 0;
|
||||||
|
<<repeat_landmark_generation>>
|
||||||
map.landmarks (index).x := core.random (6, map.width - 6);
|
map.landmarks (index).x := core.random (6, map.width - 6);
|
||||||
map.landmarks (index).y := core.random (6, map.height - 6);
|
map.landmarks (index).y := core.random (6, map.height - 6);
|
||||||
--
|
--
|
||||||
|
if map.clips (map.landmarks (index).x, map.landmarks (index).y) then
|
||||||
|
goto repeat_landmark_generation;
|
||||||
|
end if;
|
||||||
|
--
|
||||||
if landmark_trait (landmark_index'val (map.landmarks (index).index)).clip then
|
if landmark_trait (landmark_index'val (map.landmarks (index).index)).clip then
|
||||||
declare reach_x : constant natural := landmarks (landmark_index'val (map.landmarks (index).index)).width / core.base;
|
declare reach_x : constant natural := landmarks (landmark_index'val (map.landmarks (index).index)).width / core.base;
|
||||||
reach_y : constant natural := landmarks (landmark_index'val (map.landmarks (index).index)).height / core.base;
|
reach_y : constant natural := landmarks (landmark_index'val (map.landmarks (index).index)).height / core.base;
|
||||||
@ -186,9 +191,14 @@ package body world is
|
|||||||
for index in 1 .. location_limit loop
|
for index in 1 .. location_limit loop
|
||||||
map.locations (index).index := core.random (0, location_count - 1);
|
map.locations (index).index := core.random (0, location_count - 1);
|
||||||
map.locations (index).state := 0;
|
map.locations (index).state := 0;
|
||||||
|
<<repeat_location_generation>>
|
||||||
map.locations (index).x := core.random (6, map.width - 6);
|
map.locations (index).x := core.random (6, map.width - 6);
|
||||||
map.locations (index).y := core.random (6, map.height - 6);
|
map.locations (index).y := core.random (6, map.height - 6);
|
||||||
--
|
--
|
||||||
|
if map.clips (map.locations (index).x, map.locations (index).y) then
|
||||||
|
goto repeat_location_generation;
|
||||||
|
end if;
|
||||||
|
--
|
||||||
if location_trait (location_index'val (map.locations (index).index)).clip then
|
if location_trait (location_index'val (map.locations (index).index)).clip then
|
||||||
declare reach_x : constant natural := locations (location_index'val (map.locations (index).index)).width / core.base;
|
declare reach_x : constant natural := locations (location_index'val (map.locations (index).index)).width / core.base;
|
||||||
reach_y : constant natural := locations (location_index'val (map.locations (index).index)).height / core.base;
|
reach_y : constant natural := locations (location_index'val (map.locations (index).index)).height / core.base;
|
||||||
@ -205,9 +215,14 @@ package body world is
|
|||||||
for index in 1 .. construction_limit loop
|
for index in 1 .. construction_limit loop
|
||||||
map.constructions (index).index := core.random (0, construction.count - 1);
|
map.constructions (index).index := core.random (0, construction.count - 1);
|
||||||
map.constructions (index).state := 0;
|
map.constructions (index).state := 0;
|
||||||
|
<<repeat_construction_generation>>
|
||||||
map.constructions (index).x := core.random (6, map.width - 6);
|
map.constructions (index).x := core.random (6, map.width - 6);
|
||||||
map.constructions (index).y := core.random (6, map.height - 6);
|
map.constructions (index).y := core.random (6, map.height - 6);
|
||||||
--
|
--
|
||||||
|
if map.clips (map.constructions (index).x, map.constructions (index).y) then
|
||||||
|
goto repeat_construction_generation;
|
||||||
|
end if;
|
||||||
|
--
|
||||||
declare reach_x : constant natural := construction.sprite (construction.enumeration'val (map.constructions (index).index)).width / core.base;
|
declare reach_x : constant natural := construction.sprite (construction.enumeration'val (map.constructions (index).index)).width / core.base;
|
||||||
reach_y : constant natural := construction.sprite (construction.enumeration'val (map.constructions (index).index)).height / core.base;
|
reach_y : constant natural := construction.sprite (construction.enumeration'val (map.constructions (index).index)).height / core.base;
|
||||||
begin
|
begin
|
||||||
@ -222,16 +237,26 @@ package body world is
|
|||||||
for index in 1 .. equipment_limit loop
|
for index in 1 .. equipment_limit loop
|
||||||
map.equipments (index).index := core.random (0, equipment.count - 1);
|
map.equipments (index).index := core.random (0, equipment.count - 1);
|
||||||
map.equipments (index).state := 0;
|
map.equipments (index).state := 0;
|
||||||
|
<<repeat_equipment_generation>>
|
||||||
map.equipments (index).x := core.random (0, map.width - 1);
|
map.equipments (index).x := core.random (0, map.width - 1);
|
||||||
map.equipments (index).y := core.random (0, map.height - 1);
|
map.equipments (index).y := core.random (0, map.height - 1);
|
||||||
|
--
|
||||||
|
if map.clips (map.equipments (index).x, map.equipments (index).y) then
|
||||||
|
goto repeat_equipment_generation;
|
||||||
|
end if;
|
||||||
end loop;
|
end loop;
|
||||||
--
|
--
|
||||||
for index in 1 .. unit_limit loop
|
for index in 1 .. unit_limit loop
|
||||||
map.units (index).index := core.random (0, unit.count - 1);
|
map.units (index).index := core.random (0, unit.count - 1);
|
||||||
map.units (index).state := 0;
|
map.units (index).state := 0;
|
||||||
|
<<repeat_unit_generation>>
|
||||||
map.units (index).x := core.random (0, map.width - 1);
|
map.units (index).x := core.random (0, map.width - 1);
|
||||||
map.units (index).y := core.random (0, map.height - 1);
|
map.units (index).y := core.random (0, map.height - 1);
|
||||||
--
|
--
|
||||||
|
if map.clips (map.units (index).x, map.units (index).y) then
|
||||||
|
goto repeat_unit_generation;
|
||||||
|
end if;
|
||||||
|
--
|
||||||
map.clips (map.units (index).x, map.units (index).y) := true;
|
map.clips (map.units (index).x, map.units (index).y) := true;
|
||||||
end loop;
|
end loop;
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user