Added map view shading, square now...

This commit is contained in:
Ognjen Milan Robovic 2024-05-06 13:59:08 -04:00
parent a5273708f8
commit d60e511ed9
4 changed files with 108 additions and 34 deletions

View File

@ -45,6 +45,38 @@ procedure main is
------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
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;
procedure ui_main_style is procedure ui_main_style is
begin begin
ui.active := ui.style'val ((ui.style'pos (ui.active) + 1) mod (ui.style'pos (ui.style'last) + 1)); ui.active := ui.style'val ((ui.style'pos (ui.active) + 1) mod (ui.style'pos (ui.style'last) + 1));
@ -53,11 +85,6 @@ procedure main is
procedure zoom_in is begin core.zoom := 2; end zoom_in; procedure zoom_in is begin core.zoom := 2; end zoom_in;
procedure zoom_out is begin core.zoom := 1; end zoom_out; 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 := ( signal_list : constant array (core.signal_code) of access procedure := (
core.signal_up => move_camera_up'access, core.signal_up => move_camera_up'access,
core.signal_down => move_camera_down'access, core.signal_down => move_camera_down'access,

View File

@ -39,6 +39,7 @@ package body world is
-- --
map.tiles := new tile_array (0 .. map.width - 1, 0 .. map.height - 1); 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.clips := new clip_array (0 .. map.width - 1, 0 .. map.height - 1);
map.views := new view_array (0 .. map.width - 1, 0 .. map.height - 1);
map.landmarks := new entity_array (1 .. landmark_limit); map.landmarks := new entity_array (1 .. landmark_limit);
map.constructions := new entity_array (1 .. 30); map.constructions := new entity_array (1 .. 30);
map.items := new entity_array (1 .. 60); map.items := new entity_array (1 .. 60);
@ -47,6 +48,7 @@ package body world is
for y in 0 .. height - 1 loop for y in 0 .. height - 1 loop
map.tiles (x, y) := (core.random (0, 23) * core.random (0, 23)) mod 24; map.tiles (x, y) := (core.random (0, 23) * core.random (0, 23)) mod 24;
map.clips (x, y) := false; map.clips (x, y) := false;
map.views (x, y) := false;
end loop; end loop;
end loop; end loop;
-- --
@ -54,6 +56,7 @@ package body world is
map.landmarks (index).index := core.random (0, 8); map.landmarks (index).index := core.random (0, 8);
map.landmarks (index).x := core.random (0, map.width - 1); map.landmarks (index).x := core.random (0, map.width - 1);
map.landmarks (index).y := core.random (0, map.height - 1); map.landmarks (index).y := core.random (0, map.height - 1);
--
if trait (landmark_index'val (map.landmarks (index).index)).clip then if trait (landmark_index'val (map.landmarks (index).index)).clip then
map.clips (map.landmarks (index).x, map.landmarks (index).y) := true; map.clips (map.landmarks (index).x, map.landmarks (index).y) := true;
end if; end if;
@ -86,54 +89,95 @@ package body world is
render : core.vector := (map.width - 1, render : core.vector := (map.width - 1,
map.height - 1); map.height - 1);
begin begin
view;
--
for vertical in 0 .. map.height - 1 loop for vertical in 0 .. map.height - 1 loop
exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height; exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height;
-- --
for horizontal in 0 .. map.width - 1 loop for horizontal in 0 .. map.width - 1 loop
exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width; exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width;
-- --
u := core.base * biome'pos (map.kind) * 4; if map.views (horizontal, vertical) then
v := core.base * map.tiles (horizontal, vertical); u := core.base * biome'pos (map.kind) * 4;
-- v := core.base * map.tiles (horizontal, vertical);
core.draw (data => tiles, --
x => offset.x + (horizontal - core.camera.x) * core.base * core.zoom, core.draw (data => tiles,
y => offset.y + (vertical - core.camera.y) * core.base * core.zoom, x => offset.x + (horizontal - core.camera.x) * core.base * core.zoom,
u => u, y => offset.y + (vertical - core.camera.y) * core.base * core.zoom,
v => v, u => u,
width => core.base, v => v,
height => core.base); width => core.base,
--~--MOVE PLAYER TO TILE WHERE YOU CLICKED height => core.base);
--~if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom --~--MOVE PLAYER TO TILE WHERE YOU CLICKED
--~and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom --~if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom
--~and core.cursor.y > offset.y + (vertical - core.camera.y ) * core.base * core.zoom --~and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom
--~and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom --~and core.cursor.y > offset.y + (vertical - core.camera.y ) * core.base * core.zoom
--~and core.cursor_mode = 1 then --~and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom
--~core.camera.x := horizontal; --~and core.cursor_mode = 1 then
--~core.camera.y := vertical; --~core.camera.x := horizontal;
--~core.cursor_mode := 0; --~core.camera.y := vertical;
--~end if; --~core.cursor_mode := 0;
--~end if;
end if;
end loop; end loop;
end loop; end loop;
-- --
for index in 1 .. landmark_limit loop for index in 1 .. landmark_limit loop
core.draw (data => landmarks (landmark_index'val (map.landmarks (index).index)), if map.views (map.landmarks (index).x, map.landmarks (index).y) then
x => offset.x + (map.landmarks (index).x - core.camera.x) * core.base * core.zoom, core.draw (data => landmarks (landmark_index'val (map.landmarks (index).index)),
y => offset.y + (map.landmarks (index).y - core.camera.y) * core.base * core.zoom); 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);
end if;
end loop; end loop;
-- --
for index in 1 .. 30 loop for index in 1 .. 30 loop
construction.draw (construction.enumeration'val (map.constructions (index).index), if map.views (map.constructions (index).x, map.constructions (index).y) then
offset.x + (map.constructions (index).x - core.camera.x) * core.base * core.zoom, construction.draw (construction.enumeration'val (map.constructions (index).index),
offset.y + (map.constructions (index).y - core.camera.y) * core.base * core.zoom); 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);
end if;
end loop; end loop;
-- --
for index in 1 .. 60 loop for index in 1 .. 60 loop
item.draw (item.enumeration'val (map.items (index).index), if map.views (map.items (index).x, map.items (index).y) then
offset.x + (map.items (index).x - core.camera.x) * core.base * core.zoom, item.draw (item.enumeration'val (map.items (index).index),
offset.y + (map.items (index).y - core.camera.y) * core.base * core.zoom); offset.x + (map.items (index).x - core.camera.x) * core.base * core.zoom,
offset.y + (map.items (index).y - core.camera.y) * core.base * core.zoom);
end if;
end loop; 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;
--~--
--~for horizontal in 0 .. map.width - 1 loop
--~exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width;
--~--
--~u := core.base * biome'pos (map.kind) * 4;
--~v := core.base * map.tiles (horizontal, vertical);
--~--
--~core.draw (data => tiles,
--~x => offset.x + (horizontal - core.camera.x) * core.base * core.zoom,
--~y => offset.y + (vertical - core.camera.y) * core.base * core.zoom,
--~u => u,
--~v => v,
--~width => core.base,
--~height => core.base);
--~end loop;
--~end loop;
end draw; end draw;
------------------------------------------------------------------------------------------
procedure view is
view_reach : constant integer := 12;
begin
for x in 0 .. view_reach loop
for y in 0 .. view_reach loop
map.views (x + core.camera.x - view_reach / 2, y + core.camera.y - view_reach / 2) := true;
end loop;
end loop;
end view;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end world; end world;

View File

@ -32,6 +32,7 @@ package world is
type tile_array is array (natural range <>, natural range <>) of integer; type tile_array is array (natural range <>, natural range <>) of integer;
type clip_array is array (natural range <>, natural range <>) of boolean; type clip_array is array (natural range <>, natural range <>) of boolean;
type view_array is array (natural range <>, natural range <>) of boolean;
type entity_array is array (natural range <>) of entity_trait; type entity_array is array (natural range <>) of entity_trait;
type information is record type information is record
@ -40,6 +41,7 @@ package world is
height : natural; height : natural;
tiles : access tile_array; tiles : access tile_array;
clips : access clip_array; clips : access clip_array;
views : access view_array;
landmarks : access entity_array; landmarks : access entity_array;
constructions : access entity_array; constructions : access entity_array;
items : access entity_array; items : access entity_array;
@ -73,6 +75,7 @@ package world is
procedure make (index : in biome; width, height : in natural); procedure make (index : in biome; width, height : in natural);
procedure draw; procedure draw;
procedure view;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

BIN
sprite/dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B