Revision of Chad data in World package...
This commit is contained in:
parent
3af6733ebe
commit
b947518a56
@ -35,7 +35,7 @@ package body chad is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw (player : in data; x, y : in integer) is
|
||||
procedure draw (player : in value; x, y : in integer) is
|
||||
begin
|
||||
core.draw (sprite (player.index), x, y, state => player.state);
|
||||
--
|
||||
@ -46,7 +46,7 @@ package body chad is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw_data (player : in data; x, y : in integer) is
|
||||
procedure draw_data (player : in value; x, y : in integer) is
|
||||
offset : constant integer := 8;
|
||||
begin
|
||||
ui.draw_frame ("--", x, y, 360 + 2 * offset, 96 + 2 * offset);
|
||||
@ -92,14 +92,14 @@ package body chad is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw_menu (player : in data; x, y : in integer) is
|
||||
procedure draw_menu (player : in value; x, y : in integer) is
|
||||
begin
|
||||
null;
|
||||
end draw_menu;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
function take_equipment_item (player : in out data; item : in equipment.enumeration) return boolean is
|
||||
function take_equipment_item (player : in out value; item : in equipment.enumeration) return boolean is
|
||||
use type equipment.enumeration;
|
||||
begin
|
||||
if player.item_count = item_limit or item = equipment.none then
|
||||
|
@ -26,9 +26,11 @@ package chad is
|
||||
|
||||
type item_array is array (0 .. item_limit - 1) of equipment.enumeration;
|
||||
|
||||
type data is record
|
||||
type value is record
|
||||
index : enumeration;
|
||||
state : core.animation;
|
||||
x : integer;
|
||||
y : integer;
|
||||
health : core.point;
|
||||
mana : core.point;
|
||||
stamina : core.point;
|
||||
@ -40,7 +42,7 @@ package chad is
|
||||
items : item_array;
|
||||
end record;
|
||||
|
||||
type data_list is array (natural range <>) of data;
|
||||
type value_array is array (natural range <>) of value;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
@ -59,11 +61,11 @@ package chad is
|
||||
|
||||
procedure configure;
|
||||
|
||||
procedure draw (player : in data; x, y : in integer);
|
||||
procedure draw_data (player : in data; x, y : in integer);
|
||||
procedure draw_menu (player : in data; x, y : in integer);
|
||||
procedure draw (player : in value; x, y : in integer);
|
||||
procedure draw_data (player : in value; x, y : in integer);
|
||||
procedure draw_menu (player : in value; x, y : in integer);
|
||||
|
||||
function take_equipment_item (player : in out data; item : in equipment.enumeration) return boolean;
|
||||
function take_equipment_item (player : in out value; item : in equipment.enumeration) return boolean;
|
||||
|
||||
procedure draw_pepe;
|
||||
procedure draw_alice;
|
||||
|
@ -109,6 +109,15 @@ package body core is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure echo_when (condition : in boolean; status : in echo_status; text : in string) is
|
||||
begin
|
||||
if condition then
|
||||
echo (status, text);
|
||||
end if;
|
||||
end echo_when;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure dash is
|
||||
begin
|
||||
terminal (grey, bold);
|
||||
|
@ -118,7 +118,8 @@ package core is
|
||||
function "*" (data : in point; modifier : in natural) return point;
|
||||
function "/" (data : in point; modifier : in natural) return point;
|
||||
|
||||
procedure echo (status : in echo_status; text : in string);
|
||||
procedure echo ( status : in echo_status; text : in string);
|
||||
procedure echo_when (condition : in boolean; status : in echo_status; text : in string);
|
||||
|
||||
procedure dash;
|
||||
procedure semi_dash;
|
||||
|
@ -13,9 +13,9 @@ package body effect is
|
||||
case data.operation is
|
||||
when player_add =>
|
||||
case data.operator is
|
||||
when attribute_offense => core.increment (world.map.chad_data (1).attributes (attribute.offense));
|
||||
when attribute_wisdom => core.increment (world.map.chad_data (1).attributes (attribute.wisdom));
|
||||
when attribute_speed => core.increment (world.map.chad_data (1).attributes (attribute.speed));
|
||||
when attribute_offense => core.increment (world.map.chads (1).attributes (attribute.offense));
|
||||
when attribute_wisdom => core.increment (world.map.chads (1).attributes (attribute.wisdom));
|
||||
when attribute_speed => core.increment (world.map.chads (1).attributes (attribute.speed));
|
||||
when others => null;
|
||||
end case;
|
||||
when others => null;
|
||||
|
@ -21,9 +21,11 @@ procedure main is
|
||||
preview_height : integer := 0;
|
||||
text_box_height : integer := 0;
|
||||
|
||||
player : chad.data := (
|
||||
player : chad.value := (
|
||||
index => chad.ada,
|
||||
state => core.idle,
|
||||
x => 0,
|
||||
y => 0,
|
||||
health => (30, 40),
|
||||
mana => (20, 30),
|
||||
stamina => (10, 20),
|
||||
@ -74,37 +76,37 @@ procedure main is
|
||||
|
||||
procedure check_move_camera_up is
|
||||
begin
|
||||
move_camera_up;
|
||||
camera.y := clip (camera.y, 0, world.map.height - 1);
|
||||
if world.map.clips (camera.x, camera.y) then
|
||||
increment (camera.y);
|
||||
decrement (world.map.chads (1).y);
|
||||
world.map.chads (1).y := clip (world.map.chads (1).y, 0, world.map.height - 1);
|
||||
if world.map.clips (world.map.chads (1).x, world.map.chads (1).y) then
|
||||
increment (world.map.chads (1).y);
|
||||
end if;
|
||||
end check_move_camera_up;
|
||||
|
||||
procedure check_move_camera_down is
|
||||
begin
|
||||
move_camera_down;
|
||||
camera.y := clip (camera.y, 0, world.map.height - 1);
|
||||
if world.map.clips (camera.x, camera.y) then
|
||||
decrement (camera.y);
|
||||
increment (world.map.chads (1).y);
|
||||
world.map.chads (1).y := clip (world.map.chads (1).y, 0, world.map.height - 1);
|
||||
if world.map.clips (world.map.chads (1).x, world.map.chads (1).y) then
|
||||
decrement (world.map.chads (1).y);
|
||||
end if;
|
||||
end check_move_camera_down;
|
||||
|
||||
procedure check_move_camera_left is
|
||||
begin
|
||||
move_camera_left;
|
||||
camera.x := clip (camera.x, 0, world.map.width - 1);
|
||||
if world.map.clips (camera.x, camera.y) then
|
||||
increment (camera.x);
|
||||
decrement (world.map.chads (1).x);
|
||||
world.map.chads (1).x := clip (world.map.chads (1).x, 0, world.map.width - 1);
|
||||
if world.map.clips (world.map.chads (1).x, world.map.chads (1).y) then
|
||||
increment (world.map.chads (1).x);
|
||||
end if;
|
||||
end check_move_camera_left;
|
||||
|
||||
procedure check_move_camera_right is
|
||||
begin
|
||||
move_camera_right;
|
||||
camera.x := clip (camera.x, 0, world.map.width - 1);
|
||||
if world.map.clips (camera.x, camera.y) then
|
||||
decrement (camera.x);
|
||||
increment (world.map.chads (1).x);
|
||||
world.map.chads (1).x := clip (world.map.chads (1).x, 0, world.map.width - 1);
|
||||
if world.map.clips (world.map.chads (1).x, world.map.chads (1).y) then
|
||||
decrement (world.map.chads (1).x);
|
||||
end if;
|
||||
end check_move_camera_right;
|
||||
|
||||
@ -217,9 +219,8 @@ begin
|
||||
world.configure;
|
||||
--~ai.configure;
|
||||
|
||||
world.make (world.swamp, 240, 180);
|
||||
|
||||
world.add_chad (player, (0, 0, 0, 0));
|
||||
world.make (world.swamp, 240, 180, 8);
|
||||
world.add_chad (player);
|
||||
|
||||
dash;
|
||||
echo (success, "Successfully initialized game data, entering main gameplay loop.");
|
||||
@ -299,7 +300,7 @@ begin
|
||||
--
|
||||
if view_list (status_preview_panel) then
|
||||
ui.draw_tiny_menu (preview_width, 0, side_panel, preview_height);
|
||||
chad.draw_data (world.map.chad_data (1), preview_width + 32, 32);
|
||||
chad.draw_data (world.map.chads (1), preview_width + 32, 32);
|
||||
--~ui.draw_state_box (preview_width + 32, 32);
|
||||
end if;
|
||||
--
|
||||
@ -321,8 +322,6 @@ begin
|
||||
--~magic.menu (0, 0, true);
|
||||
--~might.menu (0, 0, true);
|
||||
--
|
||||
chad.draw (player, (window_width - base) / 2, (window_height - base) / 2);
|
||||
--
|
||||
--~chad.draw_alice;
|
||||
--
|
||||
--~deity.draw (deity.AEZORA, 300, 300);
|
||||
@ -330,6 +329,9 @@ begin
|
||||
--
|
||||
ui.write (framerate'image, window_width - 5 * core.icon + 3, window_height - 27);
|
||||
--
|
||||
camera.x := world.map.chads (1).x;
|
||||
camera.y := world.map.chads (1).y;
|
||||
--
|
||||
ui.synchronize;
|
||||
end loop gameplay_loop;
|
||||
|
||||
|
@ -15,7 +15,6 @@ package body world is
|
||||
construction_limit : constant natural := 120;
|
||||
equipment_limit : constant natural := 600;
|
||||
unit_limit : constant natural := 600;
|
||||
chad_limit : constant natural := 8;
|
||||
|
||||
earth : core.sprite;
|
||||
--~water : core.sprite;
|
||||
@ -62,7 +61,7 @@ package body world is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure make (index : in biome; width, height : in natural) is
|
||||
procedure make (index : in biome; width, height, chad_limit : in natural) is
|
||||
begin
|
||||
core.echo (core.comment, "-- Procedurally generating new map...");
|
||||
--
|
||||
@ -71,22 +70,23 @@ package body world is
|
||||
core.echo (core.comment, "-- -- Map height :" & height'image);
|
||||
core.echo (core.comment, "-- -- Landmark count :" & landmark_limit'image);
|
||||
--
|
||||
map.kind := index;
|
||||
map.width := width;
|
||||
map.height := height;
|
||||
map.kind := index;
|
||||
map.width := width;
|
||||
map.height := height;
|
||||
map.chad_limit := chad_limit;
|
||||
map.chad_count := 0;
|
||||
--
|
||||
map.earth := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
||||
--~map.water := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
||||
--~map.is_water := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
||||
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 entity_array (1 .. chad_limit);
|
||||
map.chad_data := new chad.data_list (1 .. chad_limit);
|
||||
map.earth := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
||||
--~map.water := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
||||
--~map.is_water := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
||||
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);
|
||||
--
|
||||
for x in 0 .. width - 1 loop
|
||||
for y in 0 .. height - 1 loop
|
||||
@ -328,7 +328,7 @@ package body world is
|
||||
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 chad.take_equipment_item (map.chad_data (1), equipment.enumeration'val (map.equipments (index).index)) then
|
||||
if chad.take_equipment_item (map.chads (1), equipment.enumeration'val (map.equipments (index).index)) then
|
||||
map.equipments (index).index := equipment.enumeration'pos (equipment.none);
|
||||
end if;
|
||||
end if;
|
||||
@ -342,6 +342,14 @@ package body world is
|
||||
end if;
|
||||
end loop;
|
||||
--
|
||||
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;
|
||||
--
|
||||
for vertical in 0 .. map.height - 1 loop
|
||||
exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height;
|
||||
--
|
||||
@ -435,10 +443,12 @@ package body world is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure add_chad (data : in chad.data; entity : in entity_trait) is
|
||||
procedure add_chad (data : in chad.value) is
|
||||
begin
|
||||
map.chads (1) := entity;
|
||||
map.chad_data (1) := data;
|
||||
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;
|
||||
end add_chad;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -54,6 +54,8 @@ package world is
|
||||
kind : biome;
|
||||
width : natural;
|
||||
height : natural;
|
||||
chad_count : natural;
|
||||
chad_limit : natural;
|
||||
earth : access integer_matrix;
|
||||
--~water : access integer_matrix;
|
||||
--~is_water : access boolean_matrix;
|
||||
@ -64,8 +66,7 @@ package world is
|
||||
constructions : access entity_array;
|
||||
equipments : access entity_array;
|
||||
units : access entity_array;
|
||||
chads : access entity_array;
|
||||
chad_data : access chad.data_list;
|
||||
chads : access chad.value_array;
|
||||
end record;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
@ -117,7 +118,7 @@ package world is
|
||||
|
||||
procedure configure;
|
||||
|
||||
procedure make (index : in biome; width, height : in natural);
|
||||
procedure make (index : in biome; width, height, chad_limit : in natural);
|
||||
|
||||
procedure draw;
|
||||
|
||||
@ -125,7 +126,7 @@ package world is
|
||||
|
||||
procedure reveal_map;
|
||||
|
||||
procedure add_chad (data : in chad.data; entity : in entity_trait);
|
||||
procedure add_chad (data : in chad.value);
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user