|
|
@@ -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,54 +89,95 @@ 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; |
|
|
|
-- |
|
|
|
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); |
|
|
|
--~--MOVE PLAYER TO TILE WHERE YOU CLICKED |
|
|
|
--~if core.cursor.x > offset.x + (horizontal - core.camera.x ) * 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 ) * core.base * core.zoom |
|
|
|
--~and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom |
|
|
|
--~and core.cursor_mode = 1 then |
|
|
|
--~core.camera.x := horizontal; |
|
|
|
--~core.camera.y := vertical; |
|
|
|
--~core.cursor_mode := 0; |
|
|
|
--~end if; |
|
|
|
if map.views (horizontal, vertical) then |
|
|
|
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); |
|
|
|
--~--MOVE PLAYER TO TILE WHERE YOU CLICKED |
|
|
|
--~if core.cursor.x > offset.x + (horizontal - core.camera.x ) * 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 ) * core.base * core.zoom |
|
|
|
--~and core.cursor.y < offset.y + (vertical - core.camera.y + 1) * core.base * core.zoom |
|
|
|
--~and core.cursor_mode = 1 then |
|
|
|
--~core.camera.x := horizontal; |
|
|
|
--~core.camera.y := vertical; |
|
|
|
--~core.cursor_mode := 0; |
|
|
|
--~end if; |
|
|
|
end if; |
|
|
|
end loop; |
|
|
|
end loop; |
|
|
|
-- |
|
|
|
for index in 1 .. landmark_limit loop |
|
|
|
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); |
|
|
|
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 |
|
|
|
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); |
|
|
|
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 |
|
|
|
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); |
|
|
|
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; |