Added map view shading, square now...
This commit is contained in:
parent
a5273708f8
commit
d60e511ed9
@ -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
|
||||
begin
|
||||
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_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 => move_camera_up'access,
|
||||
core.signal_down => move_camera_down'access,
|
||||
|
@ -39,6 +39,7 @@ package body world is
|
||||
--
|
||||
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.views := new view_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);
|
||||
@ -47,6 +48,7 @@ package body world is
|
||||
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;
|
||||
map.views (x, y) := false;
|
||||
end loop;
|
||||
end loop;
|
||||
--
|
||||
@ -54,6 +56,7 @@ 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;
|
||||
@ -86,12 +89,15 @@ package body world is
|
||||
render : core.vector := (map.width - 1,
|
||||
map.height - 1);
|
||||
begin
|
||||
view;
|
||||
--
|
||||
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;
|
||||
--
|
||||
if map.views (horizontal, vertical) then
|
||||
u := core.base * biome'pos (map.kind) * 4;
|
||||
v := core.base * map.tiles (horizontal, vertical);
|
||||
--
|
||||
@ -112,28 +118,66 @@ package body world is
|
||||
--~core.camera.y := vertical;
|
||||
--~core.cursor_mode := 0;
|
||||
--~end if;
|
||||
end if;
|
||||
end loop;
|
||||
end loop;
|
||||
--
|
||||
for index in 1 .. landmark_limit loop
|
||||
if map.views (map.landmarks (index).x, map.landmarks (index).y) then
|
||||
core.draw (data => landmarks (landmark_index'val (map.landmarks (index).index)),
|
||||
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;
|
||||
--
|
||||
for index in 1 .. 30 loop
|
||||
if map.views (map.constructions (index).x, map.constructions (index).y) then
|
||||
construction.draw (construction.enumeration'val (map.constructions (index).index),
|
||||
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;
|
||||
--
|
||||
for index in 1 .. 60 loop
|
||||
if map.views (map.items (index).x, map.items (index).y) then
|
||||
item.draw (item.enumeration'val (map.items (index).index),
|
||||
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;
|
||||
--
|
||||
--~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;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
|
@ -32,6 +32,7 @@ package world is
|
||||
|
||||
type tile_array is array (natural range <>, natural range <>) of integer;
|
||||
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 information is record
|
||||
@ -40,6 +41,7 @@ package world is
|
||||
height : natural;
|
||||
tiles : access tile_array;
|
||||
clips : access clip_array;
|
||||
views : access view_array;
|
||||
landmarks : access entity_array;
|
||||
constructions : access entity_array;
|
||||
items : access entity_array;
|
||||
@ -73,6 +75,7 @@ package world is
|
||||
procedure make (index : in biome; width, height : in natural);
|
||||
|
||||
procedure draw;
|
||||
procedure view;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
BIN
sprite/dark.png
Normal file
BIN
sprite/dark.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 122 B |
Loading…
Reference in New Issue
Block a user