Work in progress on world rendering...

This commit is contained in:
Ognjen Milan Robovic 2024-05-01 13:27:41 -04:00
parent aefcbd7216
commit 40c13d4476
2 changed files with 42 additions and 10 deletions

View File

@ -133,7 +133,7 @@ begin
world.configure;
ai.configure;
world.make (world.rough, 120, 100);
world.make (world.rough, 40, 20);
preview_width := core.window_width - side_panel;
preview_height := core.window_height - text_box_height;
@ -149,8 +149,8 @@ begin
--
exit when core.engine_active = false;
--
core.camera.x := core.clip (core.camera.x, 0, world.width - preview_width / core.base / core.zoom);
core.camera.y := core.clip (core.camera.y, 0, world.height - preview_height / core.base / core.zoom);
core.camera.x := core.clip (core.camera.x, 0, world.width);
core.camera.y := core.clip (core.camera.y, 0, world.height);
--
world.draw;
--

View File

@ -106,23 +106,55 @@ package body world is
------------------------------------------------------------------------------------------
procedure draw is
u, v : integer;
u, v : integer;
offset : core.vector := ((core.window_width - core.base) / 2, (core.window_height - core.base) / 2);
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_x in 0 .. core.window_width / core.base / core.zoom + 1 loop
u := core.base * biome'pos (map.kind) * 4;
v := core.base * map.tiles (core.camera.x + move_x, core.camera.y + move_y);
--~for move_x in 0 .. 10 loop
exit when core.camera.x > map.width;
--
core.draw (tiles, move_x * core.base * core.zoom, move_y * core.base * core.zoom, u, v, core.base, core.base);
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);
--
core.draw (data => tiles,
x => offset.x + (move_x - core.camera.x) * core.base * core.zoom,
y => offset.y + (move_y - core.camera.y) * core.base * core.zoom,
u => u,
v => v,
width => core.base-1,
height => core.base-1);
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);
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);
end loop;
end draw;
--~procedure draw is
--~u, v : integer;
--~begin
--~for move_y in 0 .. core.window_height / core.base / core.zoom + 1 loop
--~for move_x in 0 .. core.window_width / core.base / core.zoom + 1 loop
--~u := core.base * biome'pos (map.kind) * 4;
--~v := core.base * map.tiles (core.camera.x + move_x, core.camera.y + move_y);
--~--
--~core.draw (tiles, move_x * core.base * core.zoom, move_y * core.base * core.zoom, u, v, core.base, core.base);
--~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);
--~end loop;
--~end draw;
------------------------------------------------------------------------------------------