Revised some pixel art and abstracted out map frame with new sprites for it...

This commit is contained in:
Ognjen Milan Robovic 2024-05-09 06:16:11 -04:00
parent dad2e46c34
commit 8a27843637
24 changed files with 75 additions and 29 deletions

View File

@ -224,6 +224,32 @@ package body core is
------------------------------------------------------------------------------------------
procedure draw_horizontally (data : in sprite; x, y, width : in integer) is
begin
for move in 0 .. width / data.width - 1 loop
draw (data, x + move * data.width, y);
end loop;
--
if width mod data.width > 0 then
draw (data, x + (width / data.width) * data.width, y, width mod data.width, data.height);
end if;
end draw_horizontally;
------------------------------------------------------------------------------------------
procedure draw_vertically (data : in sprite; x, y, height : in integer) is
begin
for move in 0 .. height / data.height - 1 loop
draw (data, x, y + move * data.height);
end loop;
--
if height mod data.height > 0 then
draw (data, x, y + (height / data.height) * data.height, data.width, height mod data.height);
end if;
end draw_vertically;
------------------------------------------------------------------------------------------
procedure write (text : in string := "";
x : in integer := 0;
y : in integer := 0;

View File

@ -136,6 +136,9 @@ package core is
factor : in integer := zoom;
tint : in colour := (others => 255));
procedure draw_horizontally (data : in sprite; x, y, width : in integer);
procedure draw_vertically (data : in sprite; x, y, height : in integer);
procedure write (text : in string := "";
x : in integer := 0;
y : in integer := 0;

View File

@ -10,7 +10,15 @@ package body world is
view_reach : constant integer := 48;
dark : core.sprite;
dark : core.sprite;
border_upper : core.sprite;
border_lower : core.sprite;
border_left : core.sprite;
border_right : core.sprite;
corner_upper_left : core.sprite;
corner_upper_right : core.sprite;
corner_lower_left : core.sprite;
corner_lower_right : core.sprite;
------------------------------------------------------------------------------------------
@ -18,8 +26,16 @@ package body world is
begin
core.echo (core.comment, "Configuring world components...");
--
tiles := core.import_sprite ("./sprite/world/terrain/terrain.png", 1, 1);
dark := core.import_sprite ("./sprite/dark.png", 1, 1);
tiles := core.import_sprite ("./sprite/world/terrain/terrain.png", 1, 1);
dark := core.import_sprite ("./sprite/world/dark.png", 1, 1);
border_upper := core.import_sprite ("./sprite/world/frame/border_upper.png", 1, 1);
border_lower := core.import_sprite ("./sprite/world/frame/border_lower.png", 1, 1);
border_left := core.import_sprite ("./sprite/world/frame/border_left.png", 1, 1);
border_right := core.import_sprite ("./sprite/world/frame/border_right.png", 1, 1);
corner_upper_left := core.import_sprite ("./sprite/world/frame/corner_upper_left.png", 1, 1);
corner_upper_right := core.import_sprite ("./sprite/world/frame/corner_upper_right.png", 1, 1);
corner_lower_left := core.import_sprite ("./sprite/world/frame/corner_lower_left.png", 1, 1);
corner_lower_right := core.import_sprite ("./sprite/world/frame/corner_lower_right.png", 1, 1);
--
for index in landmark_index loop
declare file : constant string := core.lowercase (index'image);
@ -54,7 +70,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.tiles (x, y) := (if core.random (0, 23) < 20 then 0 else core.random (0, 23));
map.clips (x, y) := false;
map.views (x, y) := false;
end loop;
@ -120,12 +136,33 @@ package body world is
offset : core.vector := ((core.window_width - core.base) / 2,
(core.window_height - core.base) / 2);
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 not ((horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > view_reach * 2) then
map.views (horizontal, vertical) := true;
end if;
end loop;
end loop;
--
ui.draw_icon_menu (x => core.base * core.zoom * (-1- core.camera.x) + offset.x,
y => core.base * core.zoom * (-1- core.camera.y) + offset.y,
width => core.base * core.zoom * (map.width + 2),
height => core.base * core.zoom * (map.height + 2));
declare x : integer := core.base * core.zoom * (-1- core.camera.x) + offset.x;
y : integer := core.base * core.zoom * (-1- core.camera.y) + offset.y;
width : integer := core.base * core.zoom * (map.width + 2);
height : integer := core.base * core.zoom * (map.height + 2);
begin
core.draw_horizontally (border_upper, x + core.base, y, width - 2 * core.base);
core.draw_horizontally (border_lower, x + core.base, y + height - core.base, width - 2 * core.base);
core.draw_vertically (border_left, x, y + core.base, height - 2 * core.base);
core.draw_vertically (border_right, x + width - core.base, y + core.base, height - 2 * core.base);
--
core.draw (corner_upper_left, x, y);
core.draw (corner_upper_right, x + width - core.base, y);
core.draw (corner_lower_left, x, y + height - core.base);
core.draw (corner_lower_right, x + width - core.base, y + height - core.base);
end;
--
for vertical in 0 .. map.height - 1 loop
exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height;
@ -205,25 +242,6 @@ package body world is
end loop;
end draw;
------------------------------------------------------------------------------------------
procedure view is
offset : core.vector := ((core.window_width - core.base) / 2,
(core.window_height - core.base) / 2);
begin
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 not ((horizontal - core.camera.x) ** 2 + (vertical - core.camera.y) ** 2 > view_reach * 2) then
map.views (horizontal, vertical) := true;
end if;
end loop;
end loop;
end view;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end world;

View File

@ -77,7 +77,6 @@ package world is
procedure make (index : in biome; width, height : in natural);
procedure draw;
procedure view;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 B

After

Width:  |  Height:  |  Size: 202 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 B

After

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 B

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

Before

Width:  |  Height:  |  Size: 107 B

After

Width:  |  Height:  |  Size: 107 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B