From b494cf8ef7ab3a6d12b0567c0ea92acefe814316 Mon Sep 17 00:00:00 2001 From: xolatile Date: Mon, 6 May 2024 08:38:47 -0400 Subject: [PATCH] Implemented landmark collision system... --- source/main.adb | 13 +++++++++---- source/world.adb | 5 +++++ source/world.ads | 2 ++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/source/main.adb b/source/main.adb index cb9cdb3..f8efbad 100644 --- a/source/main.adb +++ b/source/main.adb @@ -53,11 +53,16 @@ procedure main is procedure zoom_in is begin core.zoom := 2; end zoom_in; procedure zoom_out is begin core.zoom := 1; end zoom_out; + procedure move_camera_up is begin core.move_camera_up; if world.map.clips (core.camera.x, core.camera.y) then core.increment (core.camera.y); end if; end move_camera_up; + procedure move_camera_down is begin core.move_camera_down; if world.map.clips (core.camera.x, core.camera.y) then core.decrement (core.camera.y); end if; end move_camera_down; + procedure move_camera_left is begin core.move_camera_left; if world.map.clips (core.camera.x, core.camera.y) then core.increment (core.camera.x); end if; end move_camera_left; + procedure move_camera_right is begin core.move_camera_right; if world.map.clips (core.camera.x, core.camera.y) then core.decrement (core.camera.x); end if; end move_camera_right; + signal_list : constant array (core.signal_code) of access procedure := ( - core.signal_up => core.move_camera_up'access, - core.signal_down => core.move_camera_down'access, - core.signal_left => core.move_camera_left'access, - core.signal_right => core.move_camera_right'access, + core.signal_up => move_camera_up'access, + core.signal_down => move_camera_down'access, + core.signal_left => move_camera_left'access, + core.signal_right => move_camera_right'access, core.signal_v => ui_main_style'access, core.signal_kp_add => zoom_in'access, core.signal_kp_subtract => zoom_out'access, diff --git a/source/world.adb b/source/world.adb index ac0611d..4808d35 100644 --- a/source/world.adb +++ b/source/world.adb @@ -38,6 +38,7 @@ package body world is map.height := height; -- map.tiles := new tile_array (0 .. map.width - 1, 0 .. map.height - 1); + map.clips := new clip_array (0 .. map.width - 1, 0 .. map.height - 1); map.landmarks := new entity_array (1 .. landmark_limit); map.constructions := new entity_array (1 .. 30); map.items := new entity_array (1 .. 60); @@ -45,6 +46,7 @@ package body world is for x in 0 .. width - 1 loop for y in 0 .. height - 1 loop map.tiles (x, y) := (core.random (0, 23) * core.random (0, 23)) mod 24; + map.clips (x, y) := false; end loop; end loop; -- @@ -52,6 +54,9 @@ package body world is map.landmarks (index).index := core.random (0, 8); map.landmarks (index).x := core.random (0, map.width - 1); map.landmarks (index).y := core.random (0, map.height - 1); + if trait (landmark_index'val (map.landmarks (index).index)).clip then + map.clips (map.landmarks (index).x, map.landmarks (index).y) := true; + end if; end loop; -- for index in 1 .. 30 loop diff --git a/source/world.ads b/source/world.ads index 768d907..17194f5 100644 --- a/source/world.ads +++ b/source/world.ads @@ -31,6 +31,7 @@ package world is end record; type tile_array is array (natural range <>, natural range <>) of integer; + type clip_array is array (natural range <>, natural range <>) of boolean; type entity_array is array (natural range <>) of entity_trait; type information is record @@ -38,6 +39,7 @@ package world is width : natural; height : natural; tiles : access tile_array; + clips : access clip_array; landmarks : access entity_array; constructions : access entity_array; items : access entity_array;