From d9fe7fa0b61112c6f80aa4f9e7af9cf3827feab8 Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 17 Jun 2024 10:55:53 -0400 Subject: [PATCH] Refactored player renaming... --- source/world.adb | 108 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 48 deletions(-) diff --git a/source/world.adb b/source/world.adb index 5a7ed33..f36d9b5 100644 --- a/source/world.adb +++ b/source/world.adb @@ -903,42 +903,46 @@ package body world is ------------------------------------------------------------------------------------------ procedure restore_points is + player : chad.information renames map.chads (1); begin - map.chads (1).health.value := map.chads (1).health.limit; - map.chads (1).mana.value := map.chads (1).mana.limit; - map.chads (1).stamina.value := map.chads (1).stamina.limit; + player.health.value := player.health.limit; + player.mana.value := player.mana.limit; + player.stamina.value := player.stamina.limit; end restore_points; ------------------------------------------------------------------------------------------ procedure increase_attributes is + player : chad.information renames map.chads (1); begin for index in attribute.enumeration loop - map.chads (1).attributes (index) := map.chads (1).attributes (index) + 1; + player.attributes (index) := player.attributes (index) + 1; end loop; end increase_attributes; ------------------------------------------------------------------------------------------ procedure increase_resources is + player : chad.information renames map.chads (1); begin for index in resource.enumeration loop - map.chads (1).resources (index) := map.chads (1).resources (index) + 10; + player.resources (index) := player.resources (index) + 10; end loop; end increase_resources; ------------------------------------------------------------------------------------------ procedure player_up is + player : chad.information renames map.chads (1); begin - if map.chads (1).stamina.value = 0 then return; end if; - core.decrement (map.chads (1).y); - core.clip (map.chads (1).y, 0, map.height - 1); - map.chads (1).stamina := map.chads (1).stamina - 1; - if map.clips (map.chads (1).x, map.chads (1).y) then - core.increment (map.chads (1).y); - if map.chads (1).stamina.value > 0 then - map.chads (1).stamina := map.chads (1).stamina + 1; + if player.stamina.value = 0 then return; end if; + core.decrement (player.y); + core.clip (player.y, 0, map.height - 1); + player.stamina := player.stamina - 1; + if map.clips (player.x, player.y) then + core.increment (player.y); + if player.stamina.value > 0 then + player.stamina := player.stamina + 1; end if; end if; end player_up; @@ -946,15 +950,16 @@ package body world is ------------------------------------------------------------------------------------------ procedure player_down is + player : chad.information renames map.chads (1); begin - if map.chads (1).stamina.value = 0 then return; end if; - core.increment (map.chads (1).y); - core.clip (map.chads (1).y, 0, map.height - 1); - map.chads (1).stamina := map.chads (1).stamina - 1; - if map.clips (map.chads (1).x, map.chads (1).y) then - core.decrement (map.chads (1).y); - if map.chads (1).stamina.value > 0 then - map.chads (1).stamina := map.chads (1).stamina + 1; + if player.stamina.value = 0 then return; end if; + core.increment (player.y); + core.clip (player.y, 0, map.height - 1); + player.stamina := player.stamina - 1; + if map.clips (player.x, player.y) then + core.decrement (player.y); + if player.stamina.value > 0 then + player.stamina := player.stamina + 1; end if; end if; end player_down; @@ -962,15 +967,16 @@ package body world is ------------------------------------------------------------------------------------------ procedure player_left is + player : chad.information renames map.chads (1); begin - if map.chads (1).stamina.value = 0 then return; end if; - core.decrement (map.chads (1).x); - core.clip (map.chads (1).x, 0, map.width - 1); - map.chads (1).stamina := map.chads (1).stamina - 1; - if map.clips (map.chads (1).x, map.chads (1).y) then - core.increment (map.chads (1).x); - if map.chads (1).stamina.value > 0 then - map.chads (1).stamina := map.chads (1).stamina + 1; + if player.stamina.value = 0 then return; end if; + core.decrement (player.x); + core.clip (player.x, 0, map.width - 1); + player.stamina := player.stamina - 1; + if map.clips (player.x, player.y) then + core.increment (player.x); + if player.stamina.value > 0 then + player.stamina := player.stamina + 1; end if; end if; end player_left; @@ -978,15 +984,16 @@ package body world is ------------------------------------------------------------------------------------------ procedure player_right is + player : chad.information renames map.chads (1); begin - if map.chads (1).stamina.value = 0 then return; end if; - core.increment (map.chads (1).x); - core.clip (map.chads (1).x, 0, map.width - 1); - map.chads (1).stamina := map.chads (1).stamina - 1; - if map.clips (map.chads (1).x, map.chads (1).y) then - core.decrement (map.chads (1).x); - if map.chads (1).stamina.value > 0 then - map.chads (1).stamina := map.chads (1).stamina + 1; + if player.stamina.value = 0 then return; end if; + core.increment (player.x); + core.clip (player.x, 0, map.width - 1); + player.stamina := player.stamina - 1; + if map.clips (player.x, player.y) then + core.decrement (player.x); + if player.stamina.value > 0 then + player.stamina := player.stamina + 1; end if; end if; end player_right; @@ -1011,6 +1018,8 @@ package body world is ------------------------------------------------------------------------------------------ procedure draw_tiles (offset, view_from, view_to : in core.vector) is + player : chad.information renames map.chads (1); + -- step : core.vector := core.camera; size : constant integer := core.base * core.zoom; hits : natural := 0; @@ -1052,8 +1061,8 @@ package body world is height => size) and core.cursor_mode = core.cursor_left and not ui.prioritize then - world.map.chads (1).x := horizontal + 1; - world.map.chads (1).y := vertical; + player.x := horizontal + 1; + player.y := vertical; end if; end if; end loop; @@ -1109,6 +1118,7 @@ package body world is ------------------------------------------------------------------------------------------ procedure compute_world_visibility_grid (offset : in core.vector) is + player : chad.information renames map.chads (1); begin for vertical in 0 .. map.height - 1 loop exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height; @@ -1116,7 +1126,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 > map.chads (1).attributes (attribute.reach).value * 64) then + if not ((horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > player.attributes (attribute.reach).value * 64) then map.views (horizontal, vertical) := true; end if; end loop; @@ -1258,6 +1268,7 @@ package body world is ------------------------------------------------------------------------------------------ procedure draw_locations (offset, view_from, view_to : in core.vector) is + player : chad.information renames map.chads (1); begin for index in 1 .. map.location_count.limit loop if map.views (map.locations (index).x, map.locations (index).y) @@ -1276,9 +1287,7 @@ package body world is and map.locations (index).used = false and core.signal_mode = core.signal_e and not ui.prioritize then - declare player : chad.information renames world.map.chads (1); - -- - data : effect.information := location.description (map.locations (index).index).evoke; + declare data : effect.information := location.description (map.locations (index).index).evoke; done : boolean := false; -- attribute_index : attribute.enumeration; @@ -1354,6 +1363,8 @@ package body world is ------------------------------------------------------------------------------------------ procedure draw_equipments (offset, view_from, view_to : in core.vector) is + player : chad.information renames map.chads (1); + -- swap : equipment.enumeration; begin for index in 1 .. map.equipment_count.limit loop @@ -1367,12 +1378,12 @@ package body world is -- if map.equipments (index).x = core.camera.x and map.equipments (index).y = core.camera.y then if core.signal_mode = core.signal_e and equipment_valid (map.equipments (index).index) then - if equipment_valid (map.chads (1).equipments (equipment.description (map.equipments (index).index).slot)) then - swap := map.chads (1).equipments (equipment.description (map.equipments (index).index).slot); - map.chads (1).equipments (equipment.description (map.equipments (index).index).slot) := map.equipments (index).index; + if equipment_valid (player.equipments (equipment.description (map.equipments (index).index).slot)) then + swap := player.equipments (equipment.description (map.equipments (index).index).slot); + player.equipments (equipment.description (map.equipments (index).index).slot) := map.equipments (index).index; map.equipments (index).index := swap; else - map.chads (1).equipments (equipment.description (map.equipments (index).index).slot) := map.equipments (index).index; + player.equipments (equipment.description (map.equipments (index).index).slot) := map.equipments (index).index; map.equipments (index).index := equipment.none; end if; end if; @@ -1416,6 +1427,7 @@ package body world is ------------------------------------------------------------------------------------------ procedure draw_alternative (offset, view_from, view_to : in core.vector) is + player : chad.information renames map.chads (1); begin for vertical in view_from.y .. view_from.y + view_to.y loop exit when vertical > map.height - 1; @@ -1423,7 +1435,7 @@ package body world is 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 > map.chads (1).attributes (attribute.reach).value * 32 then + if (horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > player.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);