Work in progress on major World refactoring...

This commit is contained in:
Ognjen Milan Robovic 2024-06-10 08:41:20 -04:00
parent 05e2e5dfd6
commit ef79bb3e11
4 changed files with 159 additions and 246 deletions

View File

@ -67,8 +67,8 @@ package chad is
view_width : constant integer := 64;
view_height : constant integer := 96;
sprite : array (enumeration) of core.sprite;
view : array (enumeration) of core.sprite;
game : array (enumeration) of core.sprite;
view : array (enumeration) of core.sprite;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

View File

@ -233,9 +233,9 @@ procedure main is
at_y := at_y + core.base;
--
for index in 0 .. unit.limit - 1 loop
world.draw_unit (player_1.units (index).index, core.walk, at_x + index * core.icon + 8, at_y + 8, 1);
world.show_unit_data := player_1.units (index).index;
ui.draw_icon_menu (at_x + index * core.icon, at_y, core.icon, 3 * core.icon, unit.description (player_1.units (index).index).name.all, world.show_unit'access);
world.review_unit_data := player_1.units (index).index;
ui.draw_icon_menu (at_x + index * core.icon, at_y, core.icon, 3 * core.icon, unit.description (player_1.units (index).index).name.all, world.review_unit'access);
world.draw_unit (player_1.units (index).index, core.walk, at_x + index * core.icon + 8, at_y + 8, 1);
end loop;
end player_information;
@ -358,8 +358,8 @@ begin
core.echo (core.comment, "Configuring" & chad.count'image & " chad components...");
--
for index in chad.enumeration loop
chad.sprite (index) := core.import_sprite (core.folder & "/game/chad/" & core.lowercase (chad.enumeration'image (index)) & ".png", 4, 6);
chad.view (index) := core.import_sprite (core.folder & "/view/chad/" & core.lowercase (chad.enumeration'image (index)) & ".png", 1, 1);
chad.game (index) := core.import_sprite (core.folder & "/game/chad/" & core.lowercase (chad.enumeration'image (index)) & ".png", 4, 6);
chad.view (index) := core.import_sprite (core.folder & "/view/chad/" & core.lowercase (chad.enumeration'image (index)) & ".png", 1, 1);
end loop;
world.configure;
@ -426,7 +426,7 @@ begin
--~core.cursor_mode := core.cursor_none;
world.load ("heyo");
--~world.load ("heyo");
ui.active := ui.style'val (faction.enumeration'pos (chad.description (player.index).kind) + 1);

View File

@ -6,8 +6,6 @@ package body world is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
view_reach : constant integer := 96;
lake_count : constant natural := 6;
target : core.vector := (-1, -1);
@ -31,23 +29,6 @@ package body world is
arrow_lower_left : core.sprite;
arrow_lower_right : core.sprite;
draw_tiles_timer : natural := 0;
draw_views_timer : natural := 0;
draw_landmarks_timer : natural := 0;
draw_locations_timer : natural := 0;
draw_constructions_timer : natural := 0;
draw_equipments_timer : natural := 0;
draw_units_timer : natural := 0;
draw_world_timer : natural := 0;
drawn_tiles : natural := 0;
drawn_views : natural := 0;
drawn_landmarks : natural := 0;
drawn_locations : natural := 0;
drawn_constructions : natural := 0;
drawn_equipments : natural := 0;
drawn_units : natural := 0;
------------------------------------------------------------------------------------------
procedure generate_lake (x, y : in integer; size : in natural);
@ -61,6 +42,7 @@ package body world is
procedure draw_constructions (offset, view_from, view_to : in core.vector);
procedure draw_equipments (offset, view_from, view_to : in core.vector);
procedure draw_units (offset, view_from, view_to : in core.vector);
procedure draw_chads (offset, view_from, view_to : in core.vector);
procedure draw_alternative (offset, view_from, view_to : in core.vector);
procedure compute_earth_to_water_transition;
@ -293,6 +275,108 @@ package body world is
------------------------------------------------------------------------------------------
procedure draw_landmark (data : in landmark.enumeration; x, y, factor : in integer) is
begin
end draw_landmark;
------------------------------------------------------------------------------------------
procedure draw_location (data : in location.enumeration; used : in boolean; x, y, factor : in integer) is
begin
end draw_location;
------------------------------------------------------------------------------------------
procedure draw_construction (data : in construction.enumeration; x, y, factor : in integer) is
begin
core.draw (construction.game (data), x, y, factor => factor);
--
if core.cursor_inside (x, y, construction.game (data).width, construction.game (data).height) and core.cursor_mode = core.cursor_middle
core.write_text_box (construction.description (data).name.all);
end if;
end draw_construction;
------------------------------------------------------------------------------------------
procedure draw_equipment (data : in equipment.enumeration; x, y, factor : in integer) is
begin
core.draw (equipment.game (data), x, y, state => core.idle, factor => factor);
--
if core.cursor_inside (x, y, equipment.game (data).width, equipment.game (data).height) and core.cursor_mode = core.cursor_middle and equipment_valid (data)
core.write_text_box (equipment.description (data).name.all);
end if;
end draw_equipment;
------------------------------------------------------------------------------------------
procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y, factor : in integer) is
begin
core.draw (unit.base (unit.description (data).kind), x, y, state => state, factor => factor);
--
for kind in equipment.kind loop
core.draw (equipment.game (unit.description (data).equipments (kind)), x, y, state => state, factor => factor);
end loop;
end draw_unit;
------------------------------------------------------------------------------------------
procedure draw_chad (data : in chad.information; state : in core.animation; x, y, factor : in integer) is
begin
core.draw (chad.game (data.index), x, y, state => state, factor => factor);
--
for kind in equipment.kind loop
core.draw (equipment.game (data.equipments (kind)), x, y, state => state, factor => factor);
end loop;
end draw_chad;
------------------------------------------------------------------------------------------
procedure review_unit is
data : unit.definition := unit.description (review_unit_data);
from : faction.definition := faction.description (data.kind);
--
offset : constant integer := 8;
more : constant natural := 10;
less : constant natural := 5;
boxy : constant natural := 3 * ui.monoheight + 2 * more;
width : constant integer := chad.view_width + 3 * 2 * core.icon + 2 * offset;
height : constant integer := chad.view_height + 8 * core.icon + 2 * core.base + boxy + 2 * offset;
begin
ui.draw_frame (core.center_x (width), core.center_y (height), width, height);
ui.draw_sprite (unit.view (review_unit_data), data.name.all, core.center_x (width) + offset, core.center_y (height) + offset, 0);
ui.write (data.name.all, core.center_x (width) + offset + unit.view_width + less, core.center_y (height) + offset + less);
--
for index in attribute.enumeration loop
ui.draw_icon_and_text (data => attribute.icon (index),
text => data.attributes (index)'image,
x => core.center_x (width) + offset + unit.view_width + (attribute.enumeration'pos (index) / 2) * 2 * core.icon,
y => core.center_y (height) + offset + core.icon + core.icon * (attribute.enumeration'pos (index) mod 2),
width => 2 * core.icon);
end loop;
--
ui.draw_separator (core.center_x (width) + offset, core.center_y (height) + offset + unit.view_height, width - 2 * offset);
--
ui.draw_text (text => "Hiring fee:" & data.hiring_fee'image & core.line_feed &
"Weekly fee:" & data.weekly_fee'image & core.line_feed &
"Battle fee:" & data.battle_fee'image,
x => core.center_x (width) + offset,
y => core.center_y (height) + offset + unit.view_height + core.base,
width => width - 2 * (offset + more),
border => more);
--
ui.draw_separator (core.center_x (width) + offset, core.center_y (height) + offset + unit.view_height + core.base + boxy, width - 2 * offset);
--
for index in equipment.kind loop
ui.draw_icon_and_text (data => (if equipment_valid (data.equipments (index)) then equipment.icon (data.equipments (index)) else equipment.slot (index)),
text => equipment.description (data.equipments (index)).name.all,
x => core.center_x (width) + offset,
y => core.center_y (height) + offset + unit.view_height + 2 * core.base + boxy + equipment.kind'pos (index) * (core.icon),
width => width - 2 * offset);
end loop;
end review_unit;
------------------------------------------------------------------------------------------
procedure make (index : in biome.enumeration; width, height, landmark_limit, location_limit, construction_limit, equipment_limit, unit_limit, chad_limit : in natural) is
begin
core.echo (core.comment, "-- Procedurally generating new map...");
@ -538,22 +622,10 @@ package body world is
------------------------------------------------------------------------------------------
procedure draw is
offset : core.vector := ((core.window_width - core.base) / 2, (core.window_height - core.base) / 2);
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);
--
time : float := 0.0;
begin
time := core.time;
--
drawn_tiles := 0;
drawn_views := 0;
drawn_landmarks := 0;
drawn_locations := 0;
drawn_constructions := 0;
drawn_equipments := 0;
drawn_units := 0;
--
core.clip (view_from.x, 0, map.width - 1);
core.clip (view_from.y, 0, map.height - 1);
core.clip (view_to.x, 0, map.width - 1);
@ -568,42 +640,13 @@ package body world is
draw_constructions (offset, view_from, view_to);
draw_equipments (offset, view_from, view_to);
draw_units (offset, view_from, view_to);
draw_chads (offset, view_from, view_to);
--
draw_alternative (offset, view_from, view_to);
--
draw_world_timer := natural (1_000_000.0 * (core.time - time));
end draw;
------------------------------------------------------------------------------------------
procedure draw_performance_box is
width : constant integer := 640;
height : constant integer := 8 * 15 + 2 * core.icon;
x : constant integer := core.center_x (width);
y : constant integer := core.center_y (height);
begin
ui.draw_text_box (x, y, width, height);
--
ui.write ("draw_tiles_timer :" & draw_tiles_timer'image, x + 3 * core.icon, y + core.icon + 0 * 15, size => 15, code => true);
ui.write ("draw_views_timer :" & draw_views_timer'image, x + 3 * core.icon, y + core.icon + 1 * 15, size => 15, code => true);
ui.write ("draw_landmarks_timer :" & draw_landmarks_timer'image, x + 3 * core.icon, y + core.icon + 2 * 15, size => 15, code => true);
ui.write ("draw_locations_timer :" & draw_locations_timer'image, x + 3 * core.icon, y + core.icon + 3 * 15, size => 15, code => true);
ui.write ("draw_constructions_timer :" & draw_constructions_timer'image, x + 3 * core.icon, y + core.icon + 4 * 15, size => 15, code => true);
ui.write ("draw_equipments_timer :" & draw_equipments_timer'image, x + 3 * core.icon, y + core.icon + 5 * 15, size => 15, code => true);
ui.write ("draw_units_timer :" & draw_units_timer'image, x + 3 * core.icon, y + core.icon + 6 * 15, size => 15, code => true);
ui.write ("draw_world_timer :" & draw_world_timer'image, x + 3 * core.icon, y + core.icon + 7 * 15, size => 15, code => true);
--
ui.write (drawn_tiles'image, x + core.icon, y + core.icon + 0 * 15, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (drawn_views'image, x + core.icon, y + core.icon + 1 * 15, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (drawn_landmarks'image, x + core.icon, y + core.icon + 2 * 15, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (drawn_locations'image, x + core.icon, y + core.icon + 3 * 15, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (drawn_constructions'image, x + core.icon, y + core.icon + 4 * 15, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (drawn_equipments'image, x + core.icon, y + core.icon + 5 * 15, size => 15, code => true, tint => (255, 0, 0, 255));
ui.write (drawn_units'image, x + core.icon, y + core.icon + 6 * 15, size => 15, code => true, tint => (255, 0, 0, 255));
end draw_performance_box;
------------------------------------------------------------------------------------------
procedure mapshot (file_path : in string) is
begin
if not map_is_revealed then
@ -801,13 +844,10 @@ package body world is
------------------------------------------------------------------------------------------
procedure draw_tiles (offset, view_from, view_to : in core.vector) is
time : float := 0.0;
step : core.vector := core.camera;
size : constant integer := core.base * core.zoom;
hits : natural := 0;
begin
time := core.time;
--
for vertical in view_from.y .. view_from.y + view_to.y loop
exit when vertical > map.height - 1;
--
@ -824,8 +864,6 @@ package body world is
height => core.base,
ignore => true);
--
core.increment (drawn_tiles);
--
if core.cursor_inside (x => offset.x + (horizontal - core.camera.x) * size,
y => offset.y + (vertical - core.camera.y) * size,
width => size,
@ -899,8 +937,6 @@ package body world is
hits := hits + 1;
end loop;
end if;
--
draw_tiles_timer := natural (1_000_000.0 * (core.time - time));
end draw_tiles;
------------------------------------------------------------------------------------------
@ -913,7 +949,7 @@ package body world is
for horizontal in 0 .. map.width - 1 loop
exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width;
--
if not ((horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > view_reach * 2) then
if not ((horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > map.chads (1).attributes (attribute.reach).value * 64) then
map.views (horizontal, vertical) := true;
end if;
end loop;
@ -942,10 +978,7 @@ package body world is
------------------------------------------------------------------------------------------
procedure draw_landmarks (offset, view_from, view_to : in core.vector) is
time : float := 0.0;
begin
time := core.time;
--
for index in 1 .. map.landmark_count.limit loop
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
@ -954,8 +987,6 @@ package body world is
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);
--
core.increment (drawn_landmarks);
--
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 => landmark.game (map.landmarks (index).index).width,
@ -966,17 +997,12 @@ package body world is
end if;
end if;
end loop;
--
draw_landmarks_timer := natural (1_000_000.0 * (core.time - time));
end draw_landmarks;
------------------------------------------------------------------------------------------
procedure draw_locations (offset, view_from, view_to : in core.vector) is
time : float := 0.0;
begin
time := core.time;
--
for index in 1 .. map.location_count.limit loop
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
@ -986,8 +1012,6 @@ package body world is
y => offset.y + (map.locations (index).y - core.camera.y) * core.base * core.zoom,
state => core.animation'val (boolean'pos (map.locations (index).used)));
--
core.increment (drawn_locations);
--
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 => location.game (map.locations (index).index).width,
@ -1010,7 +1034,7 @@ package body world is
data : effect.information := location.description (map.locations (index).index).evoke;
--
attribute_index : attribute.enumeration;
skill_index : skill.enumeration;
--~skill_index : skill.enumeration;
resource_index : resource.enumeration;
material_index : material.enumeration;
begin
@ -1042,155 +1066,54 @@ package body world is
map.locations (index).used := true;
end if;
end loop;
--
draw_locations_timer := natural (1_000_000.0 * (core.time - time));
end draw_locations;
------------------------------------------------------------------------------------------
procedure draw_constructions (offset, view_from, view_to : in core.vector) is
time : float := 0.0;
x : integer := 0;
y : integer := 0;
--
this : construction.enumeration;
begin
time := core.time;
--
for index in 1 .. map.construction_count.limit loop
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
x := offset.x + (map.constructions (index).x - core.camera.x) * core.base * core.zoom;
y := offset.y + (map.constructions (index).y - core.camera.y) * core.base * core.zoom;
this := map.constructions (index).index;
--
core.draw (construction.game (this), x, y);
--
if core.cursor_inside (x, y, construction.game (this).width, construction.game (this).height)
and core.cursor_mode = core.cursor_middle
and not ui.prioritize then
core.write_text_box (construction.description (this).name.all);
end if;
--
core.increment (drawn_constructions);
draw_construction (data => map.constructions (index).index,
x => offset.x + (map.constructions (index).x - core.camera.x) * core.base * core.zoom,
y => offset.y + (map.constructions (index).y - core.camera.y) * core.base * core.zoom,
factor => core.zoom);
end if;
end loop;
--
draw_constructions_timer := natural (1_000_000.0 * (core.time - time));
end draw_constructions;
------------------------------------------------------------------------------------------
procedure draw_equipments (offset, view_from, view_to : in core.vector) is
time : float := 0.0;
x : integer := 0;
y : integer := 0;
--
this : equipment.enumeration;
begin
time := core.time;
--
for index in 1 .. map.equipment_count.limit loop
if map.views (map.equipments (index).x, map.equipments (index).y)
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
x := offset.x + (map.equipments (index).x - core.camera.x) * core.base * core.zoom;
y := offset.y + (map.equipments (index).y - core.camera.y) * core.base * core.zoom;
this := map.equipments (index).index;
draw_equipment (data => map.equipments (index).index,
x => offset.x + (map.equipments (index).x - core.camera.x) * core.base * core.zoom,
y => offset.y + (map.equipments (index).y - core.camera.y) * core.base * core.zoom,
factor => core.zoom);
--
core.draw (equipment.game (this), x, y, state => core.idle);
--
if core.cursor_inside (x, y, equipment.game (this).width, equipment.game (this).height)
and core.cursor_mode = core.cursor_middle
and equipment_valid (this)
and not ui.prioritize then
core.write_text_box (equipment.description (this).name.all);
end if;
--
core.increment (drawn_equipments);
end if;
--
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
if map.chads (1).item_count < chad.item_limit and equipment_valid (map.equipments (index).index) then
map.chads (1).items (map.chads (1).item_count) := map.equipments (index).index;
--
core.increment (map.chads (1).item_count);
--
map.equipments (index).index := equipment.none;
if map.equipments (index).x = core.camera.x and map.equipments (index).y = core.camera.y then
if map.chads (1).item_count < chad.item_limit and equipment_valid (map.equipments (index).index) then
map.chads (1).items (map.chads (1).item_count) := map.equipments (index).index;
--
core.increment (map.chads (1).item_count);
--
map.equipments (index).index := equipment.none;
end if;
end if;
end if;
end loop;
--
draw_equipments_timer := natural (1_000_000.0 * (core.time - time));
end draw_equipments;
------------------------------------------------------------------------------------------
procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y, factor : in integer) is
begin
core.draw (unit.base (unit.description (data).kind), x, y, state => state, factor => factor);
--
for kind in equipment.kind loop
core.draw (equipment.game (unit.description (data).equipments (kind)), x, y, state => state, factor => factor);
end loop;
end draw_unit;
------------------------------------------------------------------------------------------
procedure show_unit is
data : unit.definition := unit.description (show_unit_data);
from : faction.definition := faction.description (data.kind);
--
offset : constant integer := 8;
more : constant natural := 10;
less : constant natural := 5;
boxy : constant natural := 3 * ui.monoheight + 2 * more;
width : constant integer := chad.view_width + 3 * 2 * core.icon + 2 * offset;
height : constant integer := chad.view_height + 8 * core.icon + 2 * core.base + boxy + 2 * offset;
begin
ui.draw_frame (core.center_x (width), core.center_y (height), width, height);
ui.draw_sprite (unit.view (show_unit_data), data.name.all, core.center_x (width) + offset, core.center_y (height) + offset, 0);
ui.write (data.name.all, core.center_x (width) + offset + unit.view_width + less, core.center_y (height) + offset + less);
--
for index in attribute.enumeration loop
ui.draw_icon_and_text (data => attribute.icon (index),
text => data.attributes (index)'image,
x => core.center_x (width) + offset + unit.view_width + (attribute.enumeration'pos (index) / 2) * 2 * core.icon,
y => core.center_y (height) + offset + core.icon + core.icon * (attribute.enumeration'pos (index) mod 2),
width => 2 * core.icon);
end loop;
--
ui.draw_separator (core.center_x (width) + offset, core.center_y (height) + offset + unit.view_height, width - 2 * offset);
--
ui.draw_text (text => "Hiring fee:" & data.hiring_fee'image & core.line_feed &
"Weekly fee:" & data.weekly_fee'image & core.line_feed &
"Battle fee:" & data.battle_fee'image,
x => core.center_x (width) + offset,
y => core.center_y (height) + offset + unit.view_height + core.base,
width => width - 2 * (offset + more),
border => more);
--
ui.draw_separator (core.center_x (width) + offset, core.center_y (height) + offset + unit.view_height + core.base + boxy, width - 2 * offset);
--
for index in equipment.kind loop
ui.draw_icon_and_text (data => (if equipment_valid (data.equipments (index)) then equipment.icon (data.equipments (index)) else equipment.slot (index)),
text => equipment.description (data.equipments (index)).name.all,
x => core.center_x (width) + offset,
y => core.center_y (height) + offset + unit.view_height + 2 * core.base + boxy + equipment.kind'pos (index) * (core.icon),
width => width - 2 * offset);
end loop;
end show_unit;
------------------------------------------------------------------------------------------
procedure draw_units (offset, view_from, view_to : in core.vector) is
time : float := 0.0;
begin
time := core.time;
--
for index in 1 .. map.unit_count.limit loop
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
@ -1200,56 +1123,42 @@ package body world is
x => offset.x + (map.units (index).x - core.camera.x) * core.base * core.zoom,
y => offset.y + (map.units (index).y - core.camera.y) * core.base * core.zoom,
factor => core.zoom);
--
core.increment (drawn_units);
end if;
end loop;
--
for index in 1 .. map.chad_count.value loop
if map.views (map.chads (index).x, map.chads (index).y) then
core.draw (data => chad.sprite (map.chads (index).index),
x => offset.x + (map.chads (index).x - core.camera.x) * core.base * core.zoom,
y => offset.y + (map.chads (index).y - core.camera.y) * core.base * core.zoom,
state => map.chads (index).state);
--
for kind in equipment.kind loop
core.draw (data => equipment.game (map.chads (index).equipments (kind)),
x => offset.x + (map.chads (index).x - core.camera.x) * core.base * core.zoom,
y => offset.y + (map.chads (index).y - core.camera.y) * core.base * core.zoom,
state => map.chads (index).state);
end loop;
--
core.increment (drawn_units);
end if;
end loop;
--
draw_units_timer := natural (1_000_000.0 * (core.time - time));
end draw_units;
------------------------------------------------------------------------------------------
procedure draw_alternative (offset, view_from, view_to : in core.vector) is
time : float := 0.0;
procedure draw_chads (offset, view_from, view_to : in core.vector) is
begin
for index in 1 .. map.chad_count.value loop
if map.views (map.chads (index).x, map.chads (index).y) then
draw_chad (data => map.chads (index),
state => map.chads (index).state,
x => offset.x + (map.chads (index).x - core.camera.x) * core.base * core.zoom,
y => offset.y + (map.chads (index).y - core.camera.y) * core.base * core.zoom,
factor => core.zoom);
end if;
end loop;
end draw_chads;
------------------------------------------------------------------------------------------
procedure draw_alternative (offset, view_from, view_to : in core.vector) is
begin
time := core.time;
--
for vertical in view_from.y .. view_from.y + view_to.y loop
exit when vertical > map.height - 1;
--
for horizontal in view_from.x .. view_from.x + view_to.x loop
exit when horizontal > map.width - 1;
--
if (horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > view_reach then
if (horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > map.chads (1).attributes (attribute.reach).value * 32 then
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);
--
core.increment (drawn_views);
end if;
end loop;
end loop;
--
draw_views_timer := natural (1_000_000.0 * (core.time - time));
end draw_alternative;
------------------------------------------------------------------------------------------

View File

@ -40,7 +40,7 @@ package world is
map : definition;
show_unit_data : unit.enumeration := unit.none;
review_unit_data : unit.enumeration := unit.none;
------------------------------------------------------------------------------------------
@ -61,6 +61,15 @@ package world is
procedure insert_unit (data : in unit.information);
procedure insert_chad (data : in chad.information);
procedure draw_landmark (data : in landmark.enumeration; x, y, factor : in integer);
procedure draw_location (data : in location.enumeration; used : in boolean; x, y, factor : in integer);
procedure draw_construction (data : in construction.enumeration; x, y, factor : in integer);
procedure draw_equipment (data : in equipment.enumeration; x, y, factor : in integer);
procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y, factor : in integer);
procedure draw_chad (data : in chad.information; state : in core.animation; x, y, factor : in integer);
procedure review_unit;
procedure make (index : in biome.enumeration; width, height, landmark_limit, location_limit, construction_limit, equipment_limit, unit_limit, chad_limit : in natural);
procedure save (file_name : in string);
@ -68,15 +77,10 @@ package world is
procedure draw;
procedure draw_performance_box;
procedure mapshot (file_path : in string);
function map_is_revealed return boolean;
procedure draw_unit (data : in unit.enumeration; state : in core.animation; x, y, factor : in integer);
procedure show_unit;
procedure resource_cheat_1;
procedure resource_cheat_2;
procedure resource_cheat_3;