Refactored biome-separated world rendering...
This commit is contained in:
parent
043dba7c07
commit
fc5b64532f
@ -307,6 +307,7 @@ package body core is
|
|||||||
v : in integer := 0;
|
v : in integer := 0;
|
||||||
width : in integer := 0;
|
width : in integer := 0;
|
||||||
height : in integer := 0;
|
height : in integer := 0;
|
||||||
|
ignore : in boolean := false;
|
||||||
state : in animation := idle;
|
state : in animation := idle;
|
||||||
factor : in integer := zoom;
|
factor : in integer := zoom;
|
||||||
tint : in colour := (others => 255)) is
|
tint : in colour := (others => 255)) is
|
||||||
@ -316,8 +317,8 @@ package body core is
|
|||||||
new_tint : ray.colour := (ray.colour_range (tint.r), ray.colour_range (tint.g), ray.colour_range (tint.b), ray.colour_range (tint.a));
|
new_tint : ray.colour := (ray.colour_range (tint.r), ray.colour_range (tint.g), ray.colour_range (tint.b), ray.colour_range (tint.a));
|
||||||
begin
|
begin
|
||||||
ray.draw_texture (data => texture_array (data.index),
|
ray.draw_texture (data => texture_array (data.index),
|
||||||
uv => (x => float (if u > 0 then u else (animation_time mod data.frames) * data.width),
|
uv => (x => float (if ignore then u else (animation_time mod data.frames) * data.width),
|
||||||
y => float (if v > 0 then v else (animation'pos (state) mod data.states) * data.height),
|
y => float (if ignore then v else (animation'pos (state) mod data.states) * data.height),
|
||||||
width => new_width,
|
width => new_width,
|
||||||
height => new_height),
|
height => new_height),
|
||||||
view => (x => float (x),
|
view => (x => float (x),
|
||||||
|
@ -158,6 +158,7 @@ package core is
|
|||||||
v : in integer := 0;
|
v : in integer := 0;
|
||||||
width : in integer := 0;
|
width : in integer := 0;
|
||||||
height : in integer := 0;
|
height : in integer := 0;
|
||||||
|
ignore : in boolean := false;
|
||||||
state : in animation := idle;
|
state : in animation := idle;
|
||||||
factor : in integer := zoom;
|
factor : in integer := zoom;
|
||||||
tint : in colour := (others => 255));
|
tint : in colour := (others => 255));
|
||||||
|
@ -204,7 +204,7 @@ begin
|
|||||||
world.configure;
|
world.configure;
|
||||||
--~ai.configure;
|
--~ai.configure;
|
||||||
|
|
||||||
world.make (world.swamp, 240, 180, 8);
|
world.make (world.rough, 240, 180, 8);
|
||||||
world.add_chad (player);
|
world.add_chad (player);
|
||||||
|
|
||||||
core.dash;
|
core.dash;
|
||||||
|
@ -19,7 +19,8 @@ package body world is
|
|||||||
equipment_limit : constant natural := 600;
|
equipment_limit : constant natural := 600;
|
||||||
unit_limit : constant natural := 60;
|
unit_limit : constant natural := 60;
|
||||||
|
|
||||||
earth : core.sprite;
|
tiles : array (biome) of core.sprite;
|
||||||
|
|
||||||
dark : core.sprite;
|
dark : core.sprite;
|
||||||
border_upper : core.sprite;
|
border_upper : core.sprite;
|
||||||
border_lower : core.sprite;
|
border_lower : core.sprite;
|
||||||
@ -36,7 +37,10 @@ package body world is
|
|||||||
begin
|
begin
|
||||||
core.echo (core.comment, "Configuring world components...");
|
core.echo (core.comment, "Configuring world components...");
|
||||||
--
|
--
|
||||||
earth := core.import_sprite (core.folder & "/game/world/terrain/earth.png", 1, 1);
|
for index in biome loop
|
||||||
|
tiles (index) := core.import_sprite (core.folder & "/game/world/terrain/" & core.lowercase (index'image) & ".png", 4, 1);
|
||||||
|
end loop;
|
||||||
|
--
|
||||||
dark := core.import_sprite (core.folder & "/game/world/dark.png", 1, 1);
|
dark := core.import_sprite (core.folder & "/game/world/dark.png", 1, 1);
|
||||||
border_upper := core.import_sprite (core.folder & "/game/world/frame/border_upper.png", 1, 1);
|
border_upper := core.import_sprite (core.folder & "/game/world/frame/border_upper.png", 1, 1);
|
||||||
border_lower := core.import_sprite (core.folder & "/game/world/frame/border_lower.png", 1, 1);
|
border_lower := core.import_sprite (core.folder & "/game/world/frame/border_lower.png", 1, 1);
|
||||||
@ -77,7 +81,7 @@ package body world is
|
|||||||
map.chad_limit := chad_limit;
|
map.chad_limit := chad_limit;
|
||||||
map.chad_count := 0;
|
map.chad_count := 0;
|
||||||
--
|
--
|
||||||
map.earth := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
map.tiles := new integer_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
||||||
map.clips := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
map.clips := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
||||||
map.views := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
map.views := new boolean_matrix (0 .. map.width - 1, 0 .. map.height - 1);
|
||||||
map.landmarks := new entity_array (1 .. landmark_limit);
|
map.landmarks := new entity_array (1 .. landmark_limit);
|
||||||
@ -89,7 +93,7 @@ package body world is
|
|||||||
--
|
--
|
||||||
for x in 0 .. width - 1 loop
|
for x in 0 .. width - 1 loop
|
||||||
for y in 0 .. height - 1 loop
|
for y in 0 .. height - 1 loop
|
||||||
map.earth (x, y) := (if core.random (0, 23) < 19 then core.random (0, 11) else core.random (0, 23));
|
map.tiles (x, y) := (if core.random (0, 17) > 3 then core.random (0, 5) else core.random (0, 17));
|
||||||
map.clips (x, y) := false;
|
map.clips (x, y) := false;
|
||||||
map.views (x, y) := false;
|
map.views (x, y) := false;
|
||||||
end loop;
|
end loop;
|
||||||
@ -192,7 +196,7 @@ package body world is
|
|||||||
--
|
--
|
||||||
for x in 0 .. map.width - 1 loop
|
for x in 0 .. map.width - 1 loop
|
||||||
for y in 0 .. map.height - 1 loop
|
for y in 0 .. map.height - 1 loop
|
||||||
core.io.write (file, map.earth (x, y));
|
core.io.write (file, map.tiles (x, y));
|
||||||
core.io.write (file, boolean'pos (map.clips (x, y)));
|
core.io.write (file, boolean'pos (map.clips (x, y)));
|
||||||
core.io.write (file, boolean'pos (map.views (x, y)));
|
core.io.write (file, boolean'pos (map.views (x, y)));
|
||||||
end loop;
|
end loop;
|
||||||
@ -237,7 +241,7 @@ package body world is
|
|||||||
--
|
--
|
||||||
for x in 0 .. map.width - 1 loop
|
for x in 0 .. map.width - 1 loop
|
||||||
for y in 0 .. map.height - 1 loop
|
for y in 0 .. map.height - 1 loop
|
||||||
core.io.read (file, map.earth (x, y));
|
core.io.read (file, map.tiles (x, y));
|
||||||
core.io.read (file, this); map.clips (x, y) := boolean'val (this);
|
core.io.read (file, this); map.clips (x, y) := boolean'val (this);
|
||||||
core.io.read (file, this); map.views (x, y) := boolean'val (this);
|
core.io.read (file, this); map.views (x, y) := boolean'val (this);
|
||||||
end loop;
|
end loop;
|
||||||
@ -299,13 +303,14 @@ package body world is
|
|||||||
exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width;
|
exit when offset.x + (horizontal - core.camera.x) * core.base * core.zoom > core.window_width;
|
||||||
--
|
--
|
||||||
if map.views (horizontal, vertical) then
|
if map.views (horizontal, vertical) then
|
||||||
core.draw (data => earth,
|
core.draw (data => tiles (map.kind),
|
||||||
x => offset.x + (horizontal - core.camera.x) * core.base * core.zoom,
|
x => offset.x + (horizontal - core.camera.x) * core.base * core.zoom,
|
||||||
y => offset.y + (vertical - core.camera.y) * core.base * core.zoom,
|
y => offset.y + (vertical - core.camera.y) * core.base * core.zoom,
|
||||||
u => core.base * biome'pos (map.kind) * 4,
|
u => core.base * map.tiles (horizontal, vertical),
|
||||||
v => core.base * map.earth (horizontal, vertical),
|
v => core.base * (core.animation_time mod tiles (map.kind).frames),
|
||||||
width => core.base,
|
width => core.base,
|
||||||
height => core.base);
|
height => core.base,
|
||||||
|
ignore => true);
|
||||||
--~--
|
--~--
|
||||||
if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom - 6
|
if core.cursor.x > offset.x + (horizontal - core.camera.x ) * core.base * core.zoom - 6
|
||||||
and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom + 6
|
and core.cursor.x < offset.x + (horizontal - core.camera.x + 1) * core.base * core.zoom + 6
|
||||||
@ -342,9 +347,7 @@ package body world is
|
|||||||
core.draw (data => locations (location_index'val (map.locations (index).index)),
|
core.draw (data => locations (location_index'val (map.locations (index).index)),
|
||||||
x => offset.x + (map.locations (index).x - core.camera.x) * core.base * core.zoom,
|
x => offset.x + (map.locations (index).x - core.camera.x) * core.base * core.zoom,
|
||||||
y => offset.y + (map.locations (index).y - core.camera.y) * core.base * core.zoom,
|
y => offset.y + (map.locations (index).y - core.camera.y) * core.base * core.zoom,
|
||||||
v => locations (location_index'val (map.locations (index).index)).height * map.locations (index).state,
|
state => core.animation'val (map.locations (index).state));
|
||||||
width => locations (location_index'val (map.locations (index).index)).width,
|
|
||||||
height => locations (location_index'val (map.locations (index).index)).height);
|
|
||||||
if core.cursor_inside (x => offset.x + (map.locations (index).x - core.camera.x) * core.base * core.zoom,
|
if core.cursor_inside (x => offset.x + (map.locations (index).x - core.camera.x) * core.base * core.zoom,
|
||||||
y => offset.y + (map.locations (index).y - core.camera.y) * core.base * core.zoom,
|
y => offset.y + (map.locations (index).y - core.camera.y) * core.base * core.zoom,
|
||||||
width => locations (location_index'val (map.locations (index).index)).width,
|
width => locations (location_index'val (map.locations (index).index)).width,
|
||||||
@ -443,11 +446,11 @@ package body world is
|
|||||||
--
|
--
|
||||||
for vertical in 0 .. map.height - 1 loop
|
for vertical in 0 .. map.height - 1 loop
|
||||||
for horizontal in 0 .. map.width - 1 loop
|
for horizontal in 0 .. map.width - 1 loop
|
||||||
core.render_image (data => earth,
|
core.render_image (data => tiles (map.kind),
|
||||||
x => horizontal * core.base,
|
x => horizontal * core.base,
|
||||||
y => vertical * core.base,
|
y => vertical * core.base,
|
||||||
u => core.base * biome'pos (map.kind) * 4,
|
u => core.base * map.tiles (horizontal, vertical),
|
||||||
v => core.base * map.earth (horizontal, vertical),
|
v => 0,
|
||||||
width => core.base,
|
width => core.base,
|
||||||
height => core.base);
|
height => core.base);
|
||||||
end loop;
|
end loop;
|
||||||
|
@ -56,7 +56,7 @@ package world is
|
|||||||
height : natural;
|
height : natural;
|
||||||
chad_count : natural;
|
chad_count : natural;
|
||||||
chad_limit : natural;
|
chad_limit : natural;
|
||||||
earth : access integer_matrix;
|
tiles : access integer_matrix;
|
||||||
clips : access boolean_matrix;
|
clips : access boolean_matrix;
|
||||||
views : access boolean_matrix;
|
views : access boolean_matrix;
|
||||||
landmarks : access entity_array;
|
landmarks : access entity_array;
|
||||||
|
Loading…
Reference in New Issue
Block a user