Added Pepe chad, mouse movement, limited world rendering, other work in progress...

This commit is contained in:
Ognjen Milan Robovic 2024-05-01 14:41:55 -04:00
parent 40c13d4476
commit a21e9429cd
6 changed files with 50 additions and 20 deletions

View File

@ -10,14 +10,18 @@ package body chad is
sprite : array (enumeration) of core.sprite;
pepe_the_frog : core.sprite;
------------------------------------------------------------------------------------------
procedure configure is
begin
core.echo (core.comment, "Configuring chad components...");
--
pepe_the_frog := core.import_sprite ("./sprite/unit/pepe_the_frog.png", 4, 6);
--
for index in enumeration loop
--~sprite (index) := core.import_sprite ("./sprite/chad/" & core.lowercase (enumeration'image (index)) & ".png", 1, 1);
--~sprite (index) := core.import_sprite ("./sprite/chad/" & core.lowercase (enumeration'image (index)) & ".png", 4, 6);
null;
end loop;
end configure;
@ -29,6 +33,13 @@ package body chad is
core.draw (sprite (index), x, y);
end draw;
------------------------------------------------------------------------------------------
procedure draw_pepe is
begin
core.draw (pepe_the_frog, (core.window_width - core.base) / 2, (core.window_height - core.base) / 2);
end draw_pepe;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end chad;

View File

@ -48,6 +48,8 @@ package chad is
procedure draw (index : in enumeration; x, y : in integer);
procedure draw_pepe;
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
end chad;

View File

@ -149,8 +149,8 @@ begin
--
exit when core.engine_active = false;
--
core.camera.x := core.clip (core.camera.x, 0, world.width);
core.camera.y := core.clip (core.camera.y, 0, world.height);
core.camera.x := core.clip (core.camera.x, 0, world.width - 1);
core.camera.y := core.clip (core.camera.y, 0, world.height - 1);
--
world.draw;
--
@ -171,6 +171,8 @@ begin
--
--~ui.draw_fill_bar (600, 400, 400, 0.3);
--
chad.draw_pepe;
--
ui.synchronize;
--
ui.draw_help_box (0, core.window_height - text_box_height, core.window_width, text_box_height);

View File

@ -182,6 +182,8 @@ package body ui is
procedure synchronize is
begin
prioritize := false;
--
for index in 0 .. structure_limit loop
exit when index = structure_count;
--
@ -191,6 +193,7 @@ package body ui is
--
if structure_array (index).show then
draw_structure (structure_array (index));
prioritize := true;
end if;
end loop;
end synchronize;

View File

@ -39,7 +39,8 @@ package ui is
------------------------------------------------------------------------------------------
active : style := main;
active : style := main;
prioritize : boolean := false;
------------------------------------------------------------------------------------------

View File

@ -2,7 +2,7 @@
--
-- GNU General Public Licence (version 3 or later)
with core, resource, item, unit, construction, world;
with core, ui, resource, item, unit, construction, world;
package body world is
@ -41,7 +41,7 @@ package body world is
tiles : core.sprite;
landmarks : array (landmark_index) of core.sprite;
landmark_limit : constant integer := 40;
landmark_limit : constant integer := 120;
trait : constant array (landmark_index) of landmark_trait := (
dead_tree => (ash, true, 1),
@ -96,8 +96,8 @@ package body world is
--
for index in 1 .. landmark_limit loop
map.landmarks (index).index := landmark_index'val (core.random (0, 8));
map.landmarks (index).x := core.base * core.random (1, 90);
map.landmarks (index).y := core.base * core.random (1, 60);
map.landmarks (index).x := core.random (0, width - 1);
map.landmarks (index).y := core.random (0, height - 1);
end loop;
--
core.echo (core.success, "Finished procedurally generating new map.");
@ -106,20 +106,22 @@ package body world is
------------------------------------------------------------------------------------------
procedure draw is
u, v : integer;
offset : core.vector := ((core.window_width - core.base) / 2, (core.window_height - core.base) / 2);
u : integer := 0;
v : integer := 0;
offset : core.vector := ((core.window_width - core.base) / 2,
(core.window_height - core.base) / 2);
render : core.vector := ((if (core.window_width / core.base / core.zoom + 1 < width - 1) then core.window_width / core.base / core.zoom + 1 else width - 1),
(if (core.window_height / core.base / core.zoom + 1 < height - 1) then core.window_height / core.base / core.zoom + 1 else height - 1));
begin
for move_y in 0 .. core.window_height / core.base / core.zoom + 1 loop
--~for move_y in 0 .. 10 loop
exit when core.camera.y > map.height;
for move_y in 0 .. render.y loop
--~exit when core.camera.y + move_y > render.y;
--
for move_x in 0 .. core.window_width / core.base / core.zoom + 1 loop
--~for move_x in 0 .. 10 loop
exit when core.camera.x > map.width;
for move_x in 0 .. render.x loop
--~exit when core.camera.x + move_x > render.x;
--
u := core.base * biome'pos (map.kind) * 4;
v := core.base * map.tiles (if core.camera.x + move_x,
if core.camera.y + move_y);
v := core.base * map.tiles ((core.camera.x + move_x) mod width,
(core.camera.y + move_y) mod height);
--
core.draw (data => tiles,
x => offset.x + (move_x - core.camera.x) * core.base * core.zoom,
@ -128,13 +130,22 @@ package body world is
v => v,
width => core.base-1,
height => core.base-1);
--
if core.cursor.x > offset.x + (move_x - core.camera.x) * core.base * core.zoom
and core.cursor.x < offset.x + (move_x - core.camera.x) * core.base * core.zoom + core.base * core.zoom
and core.cursor.y > offset.y + (move_y - core.camera.y) * core.base * core.zoom
and core.cursor.y < offset.y + (move_y - core.camera.y) * core.base * core.zoom + core.base * core.zoom
and core.cursor_mode = 1 and not ui.prioritize then
core.camera.x := move_x;
core.camera.y := move_y;
end if;
end loop;
end loop;
--
for index in 1 .. landmark_limit loop
core.draw (data => landmarks (map.landmarks (index).index),
x => (map.landmarks (index).x - core.camera.x * core.base) * core.zoom,
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 loop;
end draw;
--~procedure draw is