2024-04-25 00:27:13 -04:00
|
|
|
-- Copyright (c) 2024 - Ognjen 'xolatile' Milan Robovic
|
|
|
|
--
|
|
|
|
-- GNU General Public Licence (version 3 or later)
|
|
|
|
|
2024-05-19 10:33:58 -04:00
|
|
|
with core, ui, resource, equipment, unit, construction, chad, effect;
|
2024-02-15 21:03:09 -05:00
|
|
|
|
2024-05-19 15:06:20 -04:00
|
|
|
use type core.cursor_code;
|
2024-05-23 02:58:30 -04:00
|
|
|
use type core.point;
|
2024-05-19 15:06:20 -04:00
|
|
|
|
2024-02-15 21:03:09 -05:00
|
|
|
package body world is
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-17 21:00:50 -04:00
|
|
|
view_reach : constant integer := 96;
|
2024-05-08 18:06:37 -04:00
|
|
|
|
2024-05-26 16:20:08 -04:00
|
|
|
lake_count : constant natural := 6;
|
2024-05-25 08:56:49 -04:00
|
|
|
|
2024-05-19 15:06:20 -04:00
|
|
|
landmark_limit : constant integer := 90;
|
|
|
|
location_limit : constant integer := 30;
|
|
|
|
construction_limit : constant natural := 60;
|
2024-05-19 18:59:02 -04:00
|
|
|
equipment_limit : constant natural := 600;
|
2024-05-19 13:57:13 -04:00
|
|
|
unit_limit : constant natural := 60;
|
2024-05-11 05:13:45 -04:00
|
|
|
|
2024-05-25 06:33:05 -04:00
|
|
|
tiles : array (biome) of core.sprite;
|
|
|
|
|
2024-05-09 06:16:11 -04:00
|
|
|
dark : core.sprite;
|
|
|
|
border_upper : core.sprite;
|
|
|
|
border_lower : core.sprite;
|
|
|
|
border_left : core.sprite;
|
|
|
|
border_right : core.sprite;
|
|
|
|
corner_upper_left : core.sprite;
|
|
|
|
corner_upper_right : core.sprite;
|
|
|
|
corner_lower_left : core.sprite;
|
|
|
|
corner_lower_right : core.sprite;
|
2024-05-08 17:14:49 -04:00
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-26 14:56:32 -04:00
|
|
|
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
|
2024-05-26 14:15:26 -04:00
|
|
|
matrix : array (0 .. 1, 0 .. 1) of natural;
|
|
|
|
begin
|
|
|
|
for x in 1 .. map.width - 2 loop
|
|
|
|
for y in 1 .. map.height - 2 loop
|
|
|
|
matrix (0, 0) := boolean'pos (map.tiles (x - 1, y - 1) not in 18 .. 23);
|
|
|
|
matrix (1, 0) := boolean'pos (map.tiles (x, y - 1) not in 18 .. 23);
|
|
|
|
matrix (0, 1) := boolean'pos (map.tiles (x - 1, y ) not in 18 .. 23);
|
|
|
|
matrix (1, 1) := boolean'pos (map.tiles (x, y ) not in 18 .. 23);
|
|
|
|
--
|
|
|
|
if map.tiles (x, y) not in 18 .. 23 and map.tiles (x, y + 1) in 18 .. 23 then map.tiles (x, y ) := 24; end if;
|
|
|
|
if map.tiles (x, y) in 18 .. 23 and map.tiles (x, y + 1) not in 18 .. 23 then map.tiles (x, y + 1) := 25; end if;
|
|
|
|
if map.tiles (x, y) not in 18 .. 23 and map.tiles (x + 1, y ) in 18 .. 23 then map.tiles (x, y ) := 26; end if;
|
|
|
|
if map.tiles (x, y) in 18 .. 23 and map.tiles (x + 1, y ) not in 18 .. 23 then map.tiles (x + 1, y ) := 27; end if;
|
|
|
|
--
|
|
|
|
if matrix = ((1, 1), (1, 0)) then map.tiles (x - 1, y - 1) := 28;
|
|
|
|
elsif matrix = ((1, 0), (1, 1)) then map.tiles (x, y - 1) := 29;
|
|
|
|
elsif matrix = ((1, 1), (0, 1)) then map.tiles (x - 1, y ) := 30;
|
|
|
|
elsif matrix = ((0, 1), (1, 1)) then map.tiles (x, y ) := 31;
|
|
|
|
elsif matrix = ((0, 0), (0, 1)) then map.tiles (x, y ) := 32;
|
|
|
|
elsif matrix = ((0, 1), (0, 0)) then map.tiles (x - 1, y ) := 33;
|
|
|
|
elsif matrix = ((0, 0), (1, 0)) then map.tiles (x, y - 1) := 34;
|
|
|
|
elsif matrix = ((1, 0), (0, 0)) then map.tiles (x - 1, y - 1) := 35;
|
|
|
|
end if;
|
|
|
|
end loop;
|
|
|
|
end loop;
|
2024-05-26 14:56:32 -04:00
|
|
|
end compute_earth_to_water_transition;
|
2024-05-26 14:15:26 -04:00
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-02-15 21:03:09 -05:00
|
|
|
procedure configure is
|
|
|
|
begin
|
2024-03-11 08:42:25 -04:00
|
|
|
core.echo (core.comment, "Configuring world components...");
|
|
|
|
--
|
2024-05-25 06:33:05 -04:00
|
|
|
for index in biome loop
|
|
|
|
tiles (index) := core.import_sprite (core.folder & "/game/world/terrain/" & core.lowercase (index'image) & ".png", 4, 1);
|
|
|
|
end loop;
|
|
|
|
--
|
2024-05-18 15:16:09 -04:00
|
|
|
dark := core.import_sprite (core.folder & "/game/world/dark.png", 1, 1);
|
|
|
|
border_upper := core.import_sprite (core.folder & "/game/world/frame/border_upper.png", 1, 1);
|
|
|
|
border_lower := core.import_sprite (core.folder & "/game/world/frame/border_lower.png", 1, 1);
|
|
|
|
border_left := core.import_sprite (core.folder & "/game/world/frame/border_left.png", 1, 1);
|
|
|
|
border_right := core.import_sprite (core.folder & "/game/world/frame/border_right.png", 1, 1);
|
|
|
|
corner_upper_left := core.import_sprite (core.folder & "/game/world/frame/corner_upper_left.png", 1, 1);
|
|
|
|
corner_upper_right := core.import_sprite (core.folder & "/game/world/frame/corner_upper_right.png", 1, 1);
|
|
|
|
corner_lower_left := core.import_sprite (core.folder & "/game/world/frame/corner_lower_left.png", 1, 1);
|
|
|
|
corner_lower_right := core.import_sprite (core.folder & "/game/world/frame/corner_lower_right.png", 1, 1);
|
2024-02-15 21:03:09 -05:00
|
|
|
--
|
2024-04-26 19:46:09 -04:00
|
|
|
for index in landmark_index loop
|
2024-05-19 10:33:58 -04:00
|
|
|
landmarks (index) := core.import_sprite (file_path => core.folder & "/game/world/landmark/" & core.lowercase (index'image) & ".png",
|
|
|
|
frames => landmark_trait (index).frames,
|
|
|
|
states => 1);
|
|
|
|
end loop;
|
|
|
|
--
|
|
|
|
for index in location_index loop
|
|
|
|
locations (index) := core.import_sprite (file_path => core.folder & "/game/world/location/" & core.lowercase (index'image) & ".png",
|
|
|
|
frames => location_trait (index).frames,
|
|
|
|
states => location_trait (index).states);
|
2024-02-15 21:03:09 -05:00
|
|
|
end loop;
|
|
|
|
end configure;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-19 13:29:28 -04:00
|
|
|
procedure make (index : in biome; width, height, chad_limit : in natural) is
|
2024-02-15 21:03:09 -05:00
|
|
|
begin
|
2024-03-21 18:28:26 -04:00
|
|
|
core.echo (core.comment, "-- Procedurally generating new map...");
|
2024-04-25 04:14:45 -04:00
|
|
|
--
|
2024-05-05 11:38:15 -04:00
|
|
|
core.echo (core.comment, "-- -- Map type : " & index'image);
|
|
|
|
core.echo (core.comment, "-- -- Map width :" & width'image);
|
|
|
|
core.echo (core.comment, "-- -- Map height :" & height'image);
|
|
|
|
core.echo (core.comment, "-- -- Landmark count :" & landmark_limit'image);
|
2024-03-21 18:28:26 -04:00
|
|
|
--
|
2024-05-19 13:29:28 -04:00
|
|
|
map.kind := index;
|
|
|
|
map.width := width;
|
|
|
|
map.height := height;
|
|
|
|
map.chad_limit := chad_limit;
|
|
|
|
map.chad_count := 0;
|
|
|
|
--
|
2024-05-25 06:33:05 -04:00
|
|
|
map.tiles := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
2024-05-19 13:29:28 -04:00
|
|
|
map.clips := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
|
|
|
map.views := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
|
|
|
map.landmarks := new entity_array (1 .. landmark_limit);
|
|
|
|
map.locations := new entity_array (1 .. location_limit);
|
|
|
|
map.constructions := new entity_array (1 .. construction_limit);
|
|
|
|
map.equipments := new entity_array (1 .. equipment_limit);
|
|
|
|
map.units := new entity_array (1 .. unit_limit);
|
|
|
|
map.chads := new chad.value_array (1 .. map.chad_limit);
|
2024-02-15 21:03:09 -05:00
|
|
|
--
|
2024-04-27 03:49:02 -04:00
|
|
|
for x in 0 .. width - 1 loop
|
|
|
|
for y in 0 .. height - 1 loop
|
2024-05-25 06:33:05 -04:00
|
|
|
map.tiles (x, y) := (if core.random (0, 17) > 3 then core.random (0, 5) else core.random (0, 17));
|
|
|
|
map.clips (x, y) := false;
|
|
|
|
map.views (x, y) := false;
|
2024-02-15 21:03:09 -05:00
|
|
|
end loop;
|
|
|
|
end loop;
|
|
|
|
--
|
2024-05-25 08:56:49 -04:00
|
|
|
for this in 1 .. lake_count loop
|
2024-05-26 14:56:32 -04:00
|
|
|
generate_lake (x => core.random (23, map.width - 23),
|
|
|
|
y => core.random (23, map.height - 23),
|
|
|
|
size => core.random (7, 19));
|
2024-05-25 08:56:49 -04:00
|
|
|
end loop;
|
2024-05-25 08:40:28 -04:00
|
|
|
--
|
2024-05-26 14:56:32 -04:00
|
|
|
compute_earth_to_water_transition;
|
2024-05-26 14:15:26 -04:00
|
|
|
--
|
2024-05-25 15:43:54 -04:00
|
|
|
for x in 0 .. width - 1 loop
|
|
|
|
for y in 0 .. height - 1 loop
|
|
|
|
if map.tiles (x, y) > 17 then
|
|
|
|
map.clips (x, y) := true;
|
|
|
|
end if;
|
|
|
|
end loop;
|
|
|
|
end loop;
|
|
|
|
--
|
2024-04-26 19:46:09 -04:00
|
|
|
for index in 1 .. landmark_limit loop
|
2024-05-15 05:06:15 -04:00
|
|
|
map.landmarks (index).index := core.random (0, landmark_count - 1);
|
2024-05-19 12:29:15 -04:00
|
|
|
map.landmarks (index).state := 0;
|
2024-05-26 14:56:32 -04:00
|
|
|
<<repeat_landmark_generation>>
|
2024-05-06 14:35:19 -04:00
|
|
|
map.landmarks (index).x := core.random (6, map.width - 6);
|
|
|
|
map.landmarks (index).y := core.random (6, map.height - 6);
|
2024-05-06 13:59:08 -04:00
|
|
|
--
|
2024-05-26 14:56:32 -04:00
|
|
|
if map.clips (map.landmarks (index).x, map.landmarks (index).y) then
|
|
|
|
goto repeat_landmark_generation;
|
|
|
|
end if;
|
|
|
|
--
|
2024-05-19 10:33:58 -04:00
|
|
|
if landmark_trait (landmark_index'val (map.landmarks (index).index)).clip then
|
2024-05-06 14:35:19 -04:00
|
|
|
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;
|
|
|
|
begin
|
|
|
|
for x in 0 .. reach_x - 1 loop
|
|
|
|
for y in 0 .. reach_y - 1 loop
|
|
|
|
map.clips (map.landmarks (index).x + x, map.landmarks (index).y + y) := true;
|
|
|
|
end loop;
|
|
|
|
end loop;
|
|
|
|
end;
|
2024-05-06 08:38:47 -04:00
|
|
|
end if;
|
2024-02-15 21:03:09 -05:00
|
|
|
end loop;
|
|
|
|
--
|
2024-05-19 10:33:58 -04:00
|
|
|
for index in 1 .. location_limit loop
|
|
|
|
map.locations (index).index := core.random (0, location_count - 1);
|
2024-05-19 12:29:15 -04:00
|
|
|
map.locations (index).state := 0;
|
2024-05-26 14:56:32 -04:00
|
|
|
<<repeat_location_generation>>
|
2024-05-19 10:33:58 -04:00
|
|
|
map.locations (index).x := core.random (6, map.width - 6);
|
|
|
|
map.locations (index).y := core.random (6, map.height - 6);
|
|
|
|
--
|
2024-05-26 14:56:32 -04:00
|
|
|
if map.clips (map.locations (index).x, map.locations (index).y) then
|
|
|
|
goto repeat_location_generation;
|
|
|
|
end if;
|
|
|
|
--
|
2024-05-19 10:33:58 -04:00
|
|
|
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;
|
|
|
|
reach_y : constant natural := locations (location_index'val (map.locations (index).index)).height / core.base;
|
|
|
|
begin
|
|
|
|
for x in 0 .. reach_x - 1 loop
|
|
|
|
for y in 0 .. reach_y - 1 loop
|
|
|
|
map.clips (map.locations (index).x + x, map.locations (index).y + y) := true;
|
|
|
|
end loop;
|
|
|
|
end loop;
|
|
|
|
end;
|
|
|
|
end if;
|
|
|
|
end loop;
|
|
|
|
--
|
2024-05-11 05:13:45 -04:00
|
|
|
for index in 1 .. construction_limit loop
|
2024-05-05 11:46:56 -04:00
|
|
|
map.constructions (index).index := core.random (0, construction.count - 1);
|
2024-05-19 12:29:15 -04:00
|
|
|
map.constructions (index).state := 0;
|
2024-05-26 14:56:32 -04:00
|
|
|
<<repeat_construction_generation>>
|
2024-05-06 14:18:30 -04:00
|
|
|
map.constructions (index).x := core.random (6, map.width - 6);
|
|
|
|
map.constructions (index).y := core.random (6, map.height - 6);
|
|
|
|
--
|
2024-05-26 14:56:32 -04:00
|
|
|
if map.clips (map.constructions (index).x, map.constructions (index).y) then
|
|
|
|
goto repeat_construction_generation;
|
|
|
|
end if;
|
|
|
|
--
|
2024-05-06 14:18:30 -04:00
|
|
|
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;
|
|
|
|
begin
|
|
|
|
for x in 0 .. reach_x - 1 loop
|
|
|
|
for y in 0 .. reach_y - 1 loop
|
|
|
|
map.clips (map.constructions (index).x + x, map.constructions (index).y + y) := true;
|
|
|
|
end loop;
|
|
|
|
end loop;
|
|
|
|
end;
|
2024-05-05 11:46:56 -04:00
|
|
|
end loop;
|
|
|
|
--
|
2024-05-11 05:13:45 -04:00
|
|
|
for index in 1 .. equipment_limit loop
|
2024-05-11 03:38:33 -04:00
|
|
|
map.equipments (index).index := core.random (0, equipment.count - 1);
|
2024-05-19 12:29:15 -04:00
|
|
|
map.equipments (index).state := 0;
|
2024-05-26 14:56:32 -04:00
|
|
|
<<repeat_equipment_generation>>
|
2024-05-11 03:38:33 -04:00
|
|
|
map.equipments (index).x := core.random (0, map.width - 1);
|
|
|
|
map.equipments (index).y := core.random (0, map.height - 1);
|
2024-05-26 14:56:32 -04:00
|
|
|
--
|
|
|
|
if map.clips (map.equipments (index).x, map.equipments (index).y) then
|
|
|
|
goto repeat_equipment_generation;
|
|
|
|
end if;
|
2024-05-05 11:46:56 -04:00
|
|
|
end loop;
|
2024-05-05 11:38:15 -04:00
|
|
|
--
|
2024-05-11 05:13:45 -04:00
|
|
|
for index in 1 .. unit_limit loop
|
2024-05-09 05:07:20 -04:00
|
|
|
map.units (index).index := core.random (0, unit.count - 1);
|
2024-05-19 12:29:15 -04:00
|
|
|
map.units (index).state := 0;
|
2024-05-26 14:56:32 -04:00
|
|
|
<<repeat_unit_generation>>
|
2024-05-09 05:07:20 -04:00
|
|
|
map.units (index).x := core.random (0, map.width - 1);
|
|
|
|
map.units (index).y := core.random (0, map.height - 1);
|
|
|
|
--
|
2024-05-26 14:56:32 -04:00
|
|
|
if map.clips (map.units (index).x, map.units (index).y) then
|
|
|
|
goto repeat_unit_generation;
|
|
|
|
end if;
|
|
|
|
--
|
2024-05-09 05:07:20 -04:00
|
|
|
map.clips (map.units (index).x, map.units (index).y) := true;
|
|
|
|
end loop;
|
|
|
|
--
|
2024-03-21 18:28:26 -04:00
|
|
|
core.echo (core.success, "Finished procedurally generating new map.");
|
2024-02-15 21:03:09 -05:00
|
|
|
end make;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-23 08:03:38 -04:00
|
|
|
procedure save (file_name : in string) is
|
2024-05-25 03:00:30 -04:00
|
|
|
procedure save_entity (here : in core.io.file_type; data : in entity_trait) is
|
|
|
|
begin
|
|
|
|
core.io.write (here, data.index);
|
|
|
|
core.io.write (here, data.state);
|
|
|
|
core.io.write (here, data.x);
|
|
|
|
core.io.write (here, data.y);
|
|
|
|
end save_entity;
|
|
|
|
--
|
|
|
|
file : core.io.file_type;
|
2024-05-23 08:03:38 -04:00
|
|
|
begin
|
2024-05-25 03:00:30 -04:00
|
|
|
core.io.create (file, core.io.out_file, core.folder & "/map/" & file_name);
|
|
|
|
--
|
|
|
|
core.io.write (file, biome'pos (map.kind));
|
|
|
|
core.io.write (file, map.width);
|
|
|
|
core.io.write (file, map.height);
|
|
|
|
core.io.write (file, map.chad_count);
|
|
|
|
core.io.write (file, map.chad_limit);
|
|
|
|
--
|
|
|
|
for x in 0 .. map.width - 1 loop
|
|
|
|
for y in 0 .. map.height - 1 loop
|
2024-05-25 06:33:05 -04:00
|
|
|
core.io.write (file, map.tiles (x, y));
|
2024-05-25 03:00:30 -04:00
|
|
|
core.io.write (file, boolean'pos (map.clips (x, y)));
|
|
|
|
core.io.write (file, boolean'pos (map.views (x, y)));
|
2024-05-23 08:03:38 -04:00
|
|
|
end loop;
|
|
|
|
end loop;
|
|
|
|
--
|
2024-05-25 03:00:30 -04:00
|
|
|
for index in 1 .. landmark_limit loop save_entity (file, map.landmarks (index)); end loop;
|
|
|
|
for index in 1 .. location_limit loop save_entity (file, map.locations (index)); end loop;
|
|
|
|
for index in 1 .. construction_limit loop save_entity (file, map.constructions (index)); end loop;
|
|
|
|
for index in 1 .. equipment_limit loop save_entity (file, map.equipments (index)); end loop;
|
|
|
|
for index in 1 .. unit_limit loop save_entity (file, map.units (index)); end loop;
|
|
|
|
--
|
2024-05-25 03:19:58 -04:00
|
|
|
chad.save_value (file, map.chads (1));
|
|
|
|
--
|
2024-05-25 03:00:30 -04:00
|
|
|
core.io.close (file);
|
2024-05-23 08:03:38 -04:00
|
|
|
--
|
|
|
|
core.echo (core.success, "Saved current map as '" & file_name & "'.");
|
|
|
|
--
|
|
|
|
core.dash;
|
|
|
|
end save;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-25 03:53:53 -04:00
|
|
|
procedure load (file_name : in string) is
|
|
|
|
procedure load_entity (here : in core.io.file_type; data : out entity_trait) is
|
|
|
|
begin
|
|
|
|
core.io.read (here, data.index);
|
|
|
|
core.io.read (here, data.state);
|
|
|
|
core.io.read (here, data.x);
|
|
|
|
core.io.read (here, data.y);
|
|
|
|
end load_entity;
|
|
|
|
--
|
|
|
|
file : core.io.file_type;
|
|
|
|
this : integer;
|
|
|
|
begin
|
|
|
|
core.io.open (file, core.io.in_file, core.folder & "/map/" & file_name);
|
|
|
|
--
|
|
|
|
core.io.read (file, this); map.kind := biome'val (this);
|
|
|
|
core.io.read (file, map.width);
|
|
|
|
core.io.read (file, map.height);
|
|
|
|
core.io.read (file, map.chad_count);
|
|
|
|
core.io.read (file, map.chad_limit);
|
|
|
|
--
|
|
|
|
for x in 0 .. map.width - 1 loop
|
|
|
|
for y in 0 .. map.height - 1 loop
|
2024-05-25 06:33:05 -04:00
|
|
|
core.io.read (file, map.tiles (x, y));
|
2024-05-25 03:53:53 -04:00
|
|
|
core.io.read (file, this); map.clips (x, y) := boolean'val (this);
|
|
|
|
core.io.read (file, this); map.views (x, y) := boolean'val (this);
|
|
|
|
end loop;
|
|
|
|
end loop;
|
|
|
|
--
|
|
|
|
for index in 1 .. landmark_limit loop load_entity (file, map.landmarks (index)); end loop;
|
|
|
|
for index in 1 .. location_limit loop load_entity (file, map.locations (index)); end loop;
|
|
|
|
for index in 1 .. construction_limit loop load_entity (file, map.constructions (index)); end loop;
|
|
|
|
for index in 1 .. equipment_limit loop load_entity (file, map.equipments (index)); end loop;
|
|
|
|
for index in 1 .. unit_limit loop load_entity (file, map.units (index)); end loop;
|
|
|
|
--
|
|
|
|
chad.load_value (file, map.chads (1));
|
|
|
|
--
|
|
|
|
core.io.close (file);
|
|
|
|
--
|
|
|
|
core.echo (core.success, "Loaded map from file '" & file_name & "'.");
|
|
|
|
--
|
|
|
|
core.dash;
|
|
|
|
end load;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-04-27 03:49:02 -04:00
|
|
|
procedure draw is
|
2024-05-27 11:31:03 -04:00
|
|
|
offset : core.vector := ((core.window_width - core.base) / 2, (core.window_height - core.base) / 2);
|
|
|
|
view_from : core.vector := (core.camera.x - core.window_width / core.base / core.zoom / 2, core.camera.y - core.window_height / core.base / core.zoom / 2);
|
|
|
|
view_to : core.vector := (core.window_width / core.base / core.zoom, core.window_height / core.base / core.zoom);
|
|
|
|
--
|
2024-05-27 10:40:07 -04:00
|
|
|
time_0 : float := 0.0;
|
|
|
|
time_1 : float := 0.0;
|
2024-02-15 21:03:09 -05:00
|
|
|
begin
|
2024-05-27 10:40:07 -04:00
|
|
|
time_0 := core.time;
|
|
|
|
time_1 := core.time;
|
|
|
|
--
|
|
|
|
drawn_tiles := 0;
|
|
|
|
drawn_views := 0;
|
|
|
|
drawn_landmarks := 0;
|
|
|
|
drawn_locations := 0;
|
|
|
|
drawn_constructions := 0;
|
|
|
|
drawn_equipments := 0;
|
|
|
|
drawn_units := 0;
|
|
|
|
--
|
2024-05-27 11:31:03 -04:00
|
|
|
view_from.x := core.clip (view_from.x, 0, map.width - 1);
|
|
|
|
view_from.y := core.clip (view_from.y, 0, map.height - 1);
|
|
|
|
view_to.x := core.clip (view_to.x, 0, map.width - 1);
|
|
|
|
view_to.y := core.clip (view_to.y, 0, map.height - 1);
|
|
|
|
--
|
2024-05-09 06:16:11 -04:00
|
|
|
for vertical in 0 .. map.height - 1 loop
|
|
|
|
exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height;
|
|
|
|
--
|
|
|
|
for horizontal in 0 .. map.width - 1 loop
|
|
|
|
exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width;
|
|
|
|
--
|
2024-05-16 14:52:41 -04:00
|
|
|
if not ((horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > view_reach * 2) then
|
2024-05-09 06:16:11 -04:00
|
|
|
map.views (horizontal, vertical) := true;
|
|
|
|
end if;
|
|
|
|
end loop;
|
|
|
|
end loop;
|
2024-05-06 13:59:08 -04:00
|
|
|
--
|
2024-05-19 13:57:13 -04:00
|
|
|
declare x : constant integer := core.base * core.zoom * (-1 - core.camera.x) + offset.x;
|
|
|
|
y : constant integer := core.base * core.zoom * (-1 - core.camera.y) + offset.y;
|
|
|
|
width : constant integer := core.base * core.zoom * (map.width + 2);
|
|
|
|
height : constant integer := core.base * core.zoom * (map.height + 2);
|
|
|
|
begin
|
|
|
|
core.draw_horizontally (border_upper, x + core.base * core.zoom, y, width - 2 * core.base * core.zoom, core.zoom);
|
|
|
|
core.draw_horizontally (border_lower, x + core.base * core.zoom, y - core.base * core.zoom + height, width - 2 * core.base * core.zoom, core.zoom);
|
|
|
|
core.draw_vertically (border_left, x, y + core.base * core.zoom, height - 2 * core.base * core.zoom, core.zoom);
|
|
|
|
core.draw_vertically (border_right, x - core.base * core.zoom + width, y + core.base * core.zoom, height - 2 * core.base * core.zoom, core.zoom);
|
|
|
|
--
|
2024-05-19 14:34:13 -04:00
|
|
|
core.draw (corner_upper_left, x, y, factor => core.zoom);
|
|
|
|
core.draw (corner_upper_right, x - core.base * core.zoom + width, y, factor => core.zoom);
|
|
|
|
core.draw (corner_lower_left, x, y - core.base * core.zoom + height, factor => core.zoom);
|
|
|
|
core.draw (corner_lower_right, x - core.base * core.zoom + width, y - core.base * core.zoom + height, factor => core.zoom);
|
2024-05-19 13:57:13 -04:00
|
|
|
end;
|
2024-05-09 04:07:25 -04:00
|
|
|
--
|
2024-05-27 11:31:03 -04:00
|
|
|
for vertical in view_from.y .. view_from.y + view_to.y loop
|
|
|
|
exit when vertical > map.height - 1;
|
2024-05-01 13:27:41 -04:00
|
|
|
--
|
2024-05-27 11:31:03 -04:00
|
|
|
for horizontal in view_from.x .. view_from.x + view_to.x loop
|
|
|
|
exit when horizontal > map.width - 1;
|
2024-05-01 13:27:41 -04:00
|
|
|
--
|
2024-05-06 13:59:08 -04:00
|
|
|
if map.views (horizontal, vertical) then
|
2024-05-25 06:33:05 -04:00
|
|
|
core.draw (data => tiles (map.kind),
|
2024-05-06 13:59:08 -04:00
|
|
|
x => offset.x + (horizontal - core.camera.x) * core.base * core.zoom,
|
2024-05-08 17:14:49 -04:00
|
|
|
y => offset.y + (vertical - core.camera.y) * core.base * core.zoom,
|
2024-05-25 06:33:05 -04:00
|
|
|
u => core.base * map.tiles (horizontal, vertical),
|
|
|
|
v => core.base * (core.animation_time mod tiles (map.kind).frames),
|
2024-05-06 13:59:08 -04:00
|
|
|
width => core.base,
|
2024-05-25 06:33:05 -04:00
|
|
|
height => core.base,
|
|
|
|
ignore => true);
|
2024-05-27 10:40:07 -04:00
|
|
|
--
|
|
|
|
core.increment (drawn_tiles);
|
|
|
|
--
|
2024-05-19 15:06:20 -04:00
|
|
|
if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom - 6
|
|
|
|
and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom + 6
|
|
|
|
and core.cursor.y > offset.y + (vertical - core.camera.y ) * core.base * core.zoom - 6
|
|
|
|
and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom + 6
|
|
|
|
and core.cursor_mode = core.cursor_left
|
|
|
|
and not ui.prioritize then
|
|
|
|
map.chads (1).x := horizontal;
|
|
|
|
map.chads (1).y := vertical;
|
|
|
|
core.cursor_mode := core.cursor_none;
|
|
|
|
end if;
|
2024-05-06 13:59:08 -04:00
|
|
|
end if;
|
2024-02-15 21:03:09 -05:00
|
|
|
end loop;
|
|
|
|
end loop;
|
|
|
|
--
|
2024-05-27 10:40:07 -04:00
|
|
|
if core.animation_time = 0 then draw_tiles_timer := core.time - time_0; time_0 := core.time; end if;
|
|
|
|
--
|
2024-04-27 07:03:40 -04:00
|
|
|
for index in 1 .. landmark_limit loop
|
2024-05-27 11:51:57 -04:00
|
|
|
if map.views (map.landmarks (index).x, map.landmarks (index).y)
|
|
|
|
and map.landmarks (index).x > view_from.x and map.landmarks (index).x < view_from.x + view_to.x
|
|
|
|
and map.landmarks (index).y > view_from.y and map.landmarks (index).y < view_from.y + view_to.y then
|
2024-05-06 13:59:08 -04:00
|
|
|
core.draw (data => landmarks (landmark_index'val (map.landmarks (index).index)),
|
|
|
|
x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom,
|
|
|
|
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom);
|
2024-05-27 10:40:07 -04:00
|
|
|
--
|
|
|
|
core.increment (drawn_landmarks);
|
|
|
|
--
|
2024-05-27 11:31:03 -04:00
|
|
|
if core.cursor_inside (x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom,
|
|
|
|
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom,
|
|
|
|
width => landmarks (landmark_index'val (map.landmarks (index).index)).width,
|
|
|
|
height => landmarks (landmark_index'val (map.landmarks (index).index)).height)
|
2024-05-25 05:46:18 -04:00
|
|
|
and core.cursor_mode = core.cursor_middle
|
2024-05-16 15:28:02 -04:00
|
|
|
and not ui.prioritize then
|
2024-05-19 10:33:58 -04:00
|
|
|
core.write_text_box (landmark_trait (landmark_index'val (map.landmarks (index).index)).name);
|
|
|
|
end if;
|
|
|
|
end if;
|
|
|
|
end loop;
|
|
|
|
--
|
2024-05-27 10:40:07 -04:00
|
|
|
if core.animation_time = 0 then draw_landmarks_timer := core.time - time_0; time_0 := core.time; end if;
|
|
|
|
--
|
2024-05-19 10:33:58 -04:00
|
|
|
for index in 1 .. location_limit loop
|
2024-05-27 11:51:57 -04:00
|
|
|
if map.views (map.locations (index).x, map.locations (index).y)
|
|
|
|
and map.locations (index).x > view_from.x and map.locations (index).x < view_from.x + view_to.x
|
|
|
|
and map.locations (index).y > view_from.y and map.locations (index).y < view_from.y + view_to.y then
|
2024-05-19 12:29:15 -04:00
|
|
|
core.draw (data => locations (location_index'val (map.locations (index).index)),
|
|
|
|
x => offset.x + (map.locations (index).x - core.camera.x) * core.base * core.zoom,
|
|
|
|
y => offset.y + (map.locations (index).y - core.camera.y) * core.base * core.zoom,
|
2024-05-25 06:33:05 -04:00
|
|
|
state => core.animation'val (map.locations (index).state));
|
2024-05-27 10:40:07 -04:00
|
|
|
--
|
|
|
|
core.increment (drawn_locations);
|
|
|
|
--
|
2024-05-19 10:33:58 -04:00
|
|
|
if core.cursor_inside (x => offset.x + (map.locations (index).x - core.camera.x) * core.base * core.zoom,
|
|
|
|
y => offset.y + (map.locations (index).y - core.camera.y) * core.base * core.zoom,
|
|
|
|
width => locations (location_index'val (map.locations (index).index)).width,
|
|
|
|
height => locations (location_index'val (map.locations (index).index)).height)
|
2024-05-25 05:46:18 -04:00
|
|
|
and core.cursor_mode = core.cursor_middle
|
2024-05-19 10:33:58 -04:00
|
|
|
and not ui.prioritize then
|
|
|
|
core.write_text_box (location_trait (location_index'val (map.locations (index).index)).name);
|
2024-05-16 15:28:02 -04:00
|
|
|
end if;
|
2024-05-06 13:59:08 -04:00
|
|
|
end if;
|
2024-05-19 11:32:19 -04:00
|
|
|
--
|
2024-05-19 12:29:15 -04:00
|
|
|
if map.locations (index).state = 1 and core.animation_time = 0 then
|
|
|
|
map.locations (index).state := 2;
|
|
|
|
end if;
|
|
|
|
--
|
2024-05-19 11:32:19 -04:00
|
|
|
if core.camera.x > map.locations (index).x - 2
|
|
|
|
and core.camera.x < map.locations (index).x + 1 + locations (location_index'val (map.locations (index).index)).width / core.base
|
|
|
|
and core.camera.y > map.locations (index).y - 2
|
|
|
|
and core.camera.y < map.locations (index).y + 1 + locations (location_index'val (map.locations (index).index)).height / core.base
|
2024-05-19 12:29:15 -04:00
|
|
|
and map.locations (index).state = 0
|
2024-05-19 11:32:19 -04:00
|
|
|
and core.signal_code'pos (core.signal_mode) = core.signal_code'pos (core.signal_e)
|
|
|
|
and not ui.prioritize then
|
|
|
|
effect.apply (location_trait (location_index'val (map.locations (index).index)).evoke);
|
2024-05-19 12:29:15 -04:00
|
|
|
--
|
|
|
|
map.locations (index).state := 1;
|
2024-05-19 11:32:19 -04:00
|
|
|
end if;
|
2024-04-27 07:03:40 -04:00
|
|
|
end loop;
|
2024-05-05 11:46:56 -04:00
|
|
|
--
|
2024-05-27 10:40:07 -04:00
|
|
|
if core.animation_time = 0 then draw_locations_timer := core.time - time_0; time_0 := core.time; end if;
|
|
|
|
--
|
2024-05-11 05:13:45 -04:00
|
|
|
for index in 1 .. construction_limit loop
|
2024-05-27 11:51:57 -04:00
|
|
|
if map.views (map.constructions (index).x, map.constructions (index).y)
|
|
|
|
and map.constructions (index).x > view_from.x and map.constructions (index).x < view_from.x + view_to.x
|
|
|
|
and map.constructions (index).y > view_from.y and map.constructions (index).y < view_from.y + view_to.y then
|
2024-05-11 06:01:07 -04:00
|
|
|
construction.draw_plus (construction.enumeration'val (map.constructions (index).index),
|
|
|
|
offset.x + (map.constructions (index).x - core.camera.x) * core.base * core.zoom,
|
|
|
|
offset.y + (map.constructions (index).y - core.camera.y) * core.base * core.zoom);
|
2024-05-27 10:40:07 -04:00
|
|
|
--
|
|
|
|
core.increment (drawn_constructions);
|
2024-05-06 13:59:08 -04:00
|
|
|
end if;
|
2024-05-05 11:46:56 -04:00
|
|
|
end loop;
|
|
|
|
--
|
2024-05-27 10:40:07 -04:00
|
|
|
if core.animation_time = 0 then draw_constructions_timer := core.time - time_0; time_0 := core.time; end if;
|
|
|
|
--
|
2024-05-11 05:13:45 -04:00
|
|
|
for index in 1 .. equipment_limit loop
|
2024-05-27 11:51:57 -04:00
|
|
|
if map.views (map.equipments (index).x, map.equipments (index).y)
|
|
|
|
and map.equipments (index).x > view_from.x and map.equipments (index).x < view_from.x + view_to.x
|
|
|
|
and map.equipments (index).y > view_from.y and map.equipments (index).y < view_from.y + view_to.y then
|
2024-05-11 06:01:07 -04:00
|
|
|
equipment.draw_plus (equipment.enumeration'val (map.equipments (index).index),
|
|
|
|
core.idle,
|
|
|
|
offset.x + (map.equipments (index).x - core.camera.x) * core.base * core.zoom,
|
|
|
|
offset.y + (map.equipments (index).y - core.camera.y) * core.base * core.zoom);
|
2024-05-27 10:40:07 -04:00
|
|
|
--
|
|
|
|
core.increment (drawn_equipments);
|
2024-05-06 13:59:08 -04:00
|
|
|
end if;
|
2024-05-17 18:35:31 -04:00
|
|
|
--
|
|
|
|
if map.equipments (index).x = core.camera.x
|
|
|
|
and map.equipments (index).y = core.camera.y
|
|
|
|
and core.signal_code'pos (core.signal_mode) = core.signal_code'pos (core.signal_e) then
|
2024-05-19 13:29:28 -04:00
|
|
|
if chad.take_equipment_item (map.chads (1), equipment.enumeration'val (map.equipments (index).index)) then
|
2024-05-17 20:02:37 -04:00
|
|
|
map.equipments (index).index := equipment.enumeration'pos (equipment.none);
|
2024-05-17 18:35:31 -04:00
|
|
|
end if;
|
|
|
|
end if;
|
2024-05-05 11:46:56 -04:00
|
|
|
end loop;
|
2024-05-08 17:14:49 -04:00
|
|
|
--
|
2024-05-27 10:40:07 -04:00
|
|
|
if core.animation_time = 0 then draw_equipments_timer := core.time - time_0; time_0 := core.time; end if;
|
|
|
|
--
|
2024-05-11 05:13:45 -04:00
|
|
|
for index in 1 .. unit_limit loop
|
2024-05-27 11:51:57 -04:00
|
|
|
if map.views (map.units (index).x, map.units (index).y)
|
|
|
|
and map.units (index).x > view_from.x and map.units (index).x < view_from.x + view_to.x
|
|
|
|
and map.units (index).y > view_from.y and map.units (index).y < view_from.y + view_to.y then
|
2024-05-21 12:15:51 -04:00
|
|
|
unit.draw (unit.enumeration'val (map.units (index).index),
|
|
|
|
core.animation'val (map.units (index).state),
|
|
|
|
offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom,
|
|
|
|
offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom);
|
2024-05-27 10:40:07 -04:00
|
|
|
--
|
|
|
|
core.increment (drawn_units);
|
2024-05-09 05:07:20 -04:00
|
|
|
end if;
|
|
|
|
end loop;
|
|
|
|
--
|
2024-05-27 10:40:07 -04:00
|
|
|
if core.animation_time = 0 then draw_units_timer := core.time - time_0; time_0 := core.time; end if;
|
|
|
|
--
|
2024-05-19 13:29:28 -04:00
|
|
|
for index in 1 .. map.chad_count loop
|
|
|
|
if map.views (map.chads (index).x, map.chads (index).y) then
|
|
|
|
chad.draw (map.chads (index),
|
|
|
|
offset.x + (map.chads (index).x - core.camera.x) * core.base * core.zoom,
|
|
|
|
offset.y + (map.chads (index).y - core.camera.y) * core.base * core.zoom);
|
|
|
|
end if;
|
|
|
|
end loop;
|
|
|
|
--
|
2024-05-27 11:51:57 -04:00
|
|
|
for vertical in view_from.y .. view_from.y + view_to.y loop
|
|
|
|
exit when vertical > map.height - 1;
|
2024-05-08 17:14:49 -04:00
|
|
|
--
|
2024-05-27 11:51:57 -04:00
|
|
|
for horizontal in view_from.x .. view_from.x + view_to.x loop
|
|
|
|
exit when horizontal > map.width - 1;
|
|
|
|
--~for vertical in 0 .. map.height - 1 loop
|
|
|
|
--~exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height;
|
|
|
|
--~--
|
|
|
|
--~for horizontal in 0 .. map.width - 1 loop
|
|
|
|
--~exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width;
|
2024-05-08 17:14:49 -04:00
|
|
|
--
|
2024-05-09 03:53:38 -04:00
|
|
|
if (horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > view_reach then
|
2024-05-08 17:14:49 -04:00
|
|
|
core.draw (data => dark,
|
|
|
|
x => offset.x + (horizontal - core.camera.x) * core.base * core.zoom,
|
|
|
|
y => offset.y + (vertical - core.camera.y) * core.base * core.zoom);
|
2024-05-27 10:40:07 -04:00
|
|
|
--
|
|
|
|
core.increment (drawn_views);
|
2024-05-08 17:14:49 -04:00
|
|
|
end if;
|
|
|
|
end loop;
|
|
|
|
end loop;
|
2024-05-27 10:40:07 -04:00
|
|
|
--
|
|
|
|
if core.animation_time = 0 then draw_views_timer := core.time - time_0; end if;
|
|
|
|
if core.animation_time = 0 then draw_world_timer := core.time - time_1; end if;
|
2024-02-15 21:03:09 -05:00
|
|
|
end draw;
|
|
|
|
|
2024-05-09 15:54:39 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure mapshot (file_path : in string) is
|
|
|
|
begin
|
2024-05-22 21:22:34 -04:00
|
|
|
if not map_is_revealed then
|
|
|
|
core.echo (core.warning, "You need to reveal entire map in order to make a mapshot.");
|
|
|
|
--
|
|
|
|
return;
|
|
|
|
end if;
|
|
|
|
--
|
2024-05-23 08:03:38 -04:00
|
|
|
core.create_image (map.width * core.base, map.height * core.base);
|
2024-05-09 15:54:39 -04:00
|
|
|
--
|
|
|
|
for vertical in 0 .. map.height - 1 loop
|
|
|
|
for horizontal in 0 .. map.width - 1 loop
|
2024-05-25 06:33:05 -04:00
|
|
|
core.render_image (data => tiles (map.kind),
|
2024-05-09 15:54:39 -04:00
|
|
|
x => horizontal * core.base,
|
|
|
|
y => vertical * core.base,
|
2024-05-25 06:33:05 -04:00
|
|
|
u => core.base * map.tiles (horizontal, vertical),
|
|
|
|
v => 0,
|
2024-05-09 15:54:39 -04:00
|
|
|
width => core.base,
|
|
|
|
height => core.base);
|
|
|
|
end loop;
|
|
|
|
end loop;
|
|
|
|
--
|
|
|
|
for index in 1 .. landmark_limit loop
|
|
|
|
core.render_image (data => landmarks (landmark_index'val (map.landmarks (index).index)),
|
|
|
|
x => map.landmarks (index).x * core.base,
|
|
|
|
y => map.landmarks (index).y * core.base,
|
|
|
|
u => 0,
|
|
|
|
v => 0,
|
|
|
|
width => landmarks (landmark_index'val (map.landmarks (index).index)).width,
|
|
|
|
height => landmarks (landmark_index'val (map.landmarks (index).index)).height);
|
|
|
|
end loop;
|
|
|
|
--
|
2024-05-19 10:33:58 -04:00
|
|
|
for index in 1 .. location_limit loop
|
|
|
|
core.render_image (data => locations (location_index'val (map.locations (index).index)),
|
|
|
|
x => map.locations (index).x * core.base,
|
|
|
|
y => map.locations (index).y * core.base,
|
|
|
|
u => 0,
|
|
|
|
v => 0,
|
|
|
|
width => locations (location_index'val (map.locations (index).index)).width,
|
|
|
|
height => locations (location_index'val (map.locations (index).index)).height);
|
|
|
|
end loop;
|
|
|
|
--
|
2024-05-11 05:13:45 -04:00
|
|
|
for index in 1 .. construction_limit loop
|
2024-05-09 15:54:39 -04:00
|
|
|
core.render_image (data => construction.sprite (construction.enumeration'val (map.constructions (index).index)),
|
2024-05-16 15:31:48 -04:00
|
|
|
x => map.constructions (index).x * core.base,
|
|
|
|
y => map.constructions (index).y * core.base,
|
2024-05-09 15:54:39 -04:00
|
|
|
u => 0,
|
|
|
|
v => 0,
|
|
|
|
width => construction.sprite (construction.enumeration'val (map.constructions (index).index)).width,
|
|
|
|
height => construction.sprite (construction.enumeration'val (map.constructions (index).index)).height);
|
|
|
|
end loop;
|
|
|
|
--
|
2024-05-11 05:13:45 -04:00
|
|
|
for index in 1 .. equipment_limit loop
|
2024-05-11 03:38:33 -04:00
|
|
|
core.render_image (data => equipment.sprite (equipment.enumeration'val (map.equipments (index).index)),
|
2024-05-16 15:31:48 -04:00
|
|
|
x => map.equipments (index).x * core.base,
|
|
|
|
y => map.equipments (index).y * core.base,
|
2024-05-09 15:54:39 -04:00
|
|
|
u => 0,
|
|
|
|
v => 0,
|
2024-05-11 03:38:33 -04:00
|
|
|
width => equipment.sprite (equipment.enumeration'val (map.equipments (index).index)).width,
|
|
|
|
height => equipment.sprite (equipment.enumeration'val (map.equipments (index).index)).height);
|
2024-05-09 15:54:39 -04:00
|
|
|
end loop;
|
|
|
|
--
|
|
|
|
core.export_image (file_path);
|
|
|
|
--
|
|
|
|
core.echo (core.success, "Exported current world mapshot.");
|
|
|
|
--
|
|
|
|
core.dash;
|
|
|
|
end mapshot;
|
|
|
|
|
2024-05-12 10:07:37 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-22 21:22:34 -04:00
|
|
|
function map_is_revealed return boolean is
|
2024-05-12 10:07:37 -04:00
|
|
|
begin
|
|
|
|
for x in 0 .. map.width - 1 loop
|
|
|
|
for y in 0 .. map.height - 1 loop
|
2024-05-22 21:22:34 -04:00
|
|
|
if map.views (x, y) = false then
|
|
|
|
return false;
|
|
|
|
end if;
|
2024-05-12 10:07:37 -04:00
|
|
|
end loop;
|
|
|
|
end loop;
|
2024-05-22 21:22:34 -04:00
|
|
|
--
|
|
|
|
return true;
|
|
|
|
end map_is_revealed;
|
2024-05-12 10:07:37 -04:00
|
|
|
|
2024-05-17 18:35:31 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
2024-05-19 13:29:28 -04:00
|
|
|
procedure add_chad (data : in chad.value) is
|
2024-05-17 18:35:31 -04:00
|
|
|
begin
|
2024-05-19 13:29:28 -04:00
|
|
|
core.echo_when (map.chad_count = map.chad_limit, core.failure, "Can't add new chad, limit reached.");
|
|
|
|
core.increment (map.chad_count);
|
|
|
|
--
|
|
|
|
map.chads (map.chad_count) := data;
|
2024-05-17 18:35:31 -04:00
|
|
|
end add_chad;
|
|
|
|
|
2024-05-22 21:22:34 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure resource_cheat_1 is begin map.chads (1).resources (resource.gold) := map.chads (1).resources (resource.gold) + 127; end resource_cheat_1;
|
|
|
|
procedure resource_cheat_2 is begin map.chads (1).resources (resource.wood) := map.chads (1).resources (resource.wood) + 127; end resource_cheat_2;
|
|
|
|
procedure resource_cheat_3 is begin map.chads (1).resources (resource.stone) := map.chads (1).resources (resource.stone) + 127; end resource_cheat_3;
|
|
|
|
procedure resource_cheat_4 is begin map.chads (1).resources (resource.metal) := map.chads (1).resources (resource.metal) + 127; end resource_cheat_4;
|
|
|
|
procedure resource_cheat_5 is begin map.chads (1).resources (resource.leather) := map.chads (1).resources (resource.leather) + 127; end resource_cheat_5;
|
|
|
|
procedure resource_cheat_6 is begin map.chads (1).resources (resource.gem) := map.chads (1).resources (resource.gem) + 127; end resource_cheat_6;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure reveal_map is
|
|
|
|
begin
|
|
|
|
for x in 0 .. map.width - 1 loop
|
|
|
|
for y in 0 .. map.height - 1 loop
|
|
|
|
map.views (x, y) := true;
|
|
|
|
end loop;
|
|
|
|
end loop;
|
|
|
|
end reveal_map;
|
|
|
|
|
2024-05-25 01:48:03 -04:00
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure player_up is
|
|
|
|
begin
|
|
|
|
core.decrement (map.chads (1).y);
|
|
|
|
map.chads (1).y := core.clip (map.chads (1).y, 0, map.height - 1);
|
|
|
|
if map.clips (map.chads (1).x, map.chads (1).y) then
|
|
|
|
core.increment (map.chads (1).y);
|
|
|
|
end if;
|
|
|
|
end player_up;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure player_down is
|
|
|
|
begin
|
|
|
|
core.increment (map.chads (1).y);
|
|
|
|
map.chads (1).y := core.clip (map.chads (1).y, 0, map.height - 1);
|
|
|
|
if map.clips (map.chads (1).x, map.chads (1).y) then
|
|
|
|
core.decrement (map.chads (1).y);
|
|
|
|
end if;
|
|
|
|
end player_down;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure player_left is
|
|
|
|
begin
|
|
|
|
core.decrement (map.chads (1).x);
|
|
|
|
map.chads (1).x := core.clip (map.chads (1).x, 0, map.width - 1);
|
|
|
|
if map.clips (map.chads (1).x, map.chads (1).y) then
|
|
|
|
core.increment (map.chads (1).x);
|
|
|
|
end if;
|
|
|
|
end player_left;
|
|
|
|
|
|
|
|
------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
procedure player_right is
|
|
|
|
begin
|
|
|
|
core.increment (map.chads (1).x);
|
|
|
|
map.chads (1).x := core.clip (map.chads (1).x, 0, map.width - 1);
|
|
|
|
if map.clips (map.chads (1).x, map.chads (1).y) then
|
|
|
|
core.decrement (map.chads (1).x);
|
|
|
|
end if;
|
|
|
|
end player_right;
|
|
|
|
|
2024-02-15 21:03:09 -05:00
|
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
end world;
|