Fixed world UV rendering bug, added Alice into dumb rendering process.
This commit is contained in:
parent
c41bab9696
commit
cc7c27833d
@ -11,6 +11,7 @@ package body chad is
|
||||
sprite : array (enumeration) of core.sprite;
|
||||
|
||||
pepe_the_frog : core.sprite;
|
||||
alice_the_mad : core.sprite;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
@ -19,6 +20,7 @@ package body chad is
|
||||
core.echo (core.comment, "Configuring chad components...");
|
||||
--
|
||||
pepe_the_frog := core.import_sprite ("./sprite/unit/pepe_the_frog.png", 4, 6);
|
||||
alice_the_mad := core.import_sprite ("./sprite/unit/alice_the_mad.png", 4, 6);
|
||||
--
|
||||
for index in enumeration loop
|
||||
--~sprite (index) := core.import_sprite ("./sprite/chad/" & core.lowercase (enumeration'image (index)) & ".png", 4, 6);
|
||||
@ -40,6 +42,13 @@ package body chad is
|
||||
core.draw (pepe_the_frog, (core.window_width - core.base) / 2, (core.window_height - core.base) / 2);
|
||||
end draw_pepe;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure draw_alice is
|
||||
begin
|
||||
core.draw (alice_the_mad, (core.window_width - core.base) / 2, (core.window_height - core.base) / 2);
|
||||
end draw_alice;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
end chad;
|
||||
|
@ -49,6 +49,7 @@ package chad is
|
||||
procedure draw (index : in enumeration; x, y : in integer);
|
||||
|
||||
procedure draw_pepe;
|
||||
procedure draw_alice;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -131,7 +131,7 @@ begin
|
||||
world.configure;
|
||||
ai.configure;
|
||||
|
||||
world.make (world.rough, 140, 120);
|
||||
world.make (world.grass, 140, 120);
|
||||
|
||||
core.dash;
|
||||
core.echo (core.success, "Successfully initialized game data, entering main gameplay loop.");
|
||||
@ -149,8 +149,8 @@ begin
|
||||
preview_height := core.window_height - text_box_height;
|
||||
text_box_height := 32;
|
||||
--
|
||||
core.camera.x := core.clip (core.camera.x, 0, world.width - 1);
|
||||
core.camera.y := core.clip (core.camera.y, 0, world.height - 1);
|
||||
core.camera.x := core.clip (core.camera.x, 0, world.map.width - 1);
|
||||
core.camera.y := core.clip (core.camera.y, 0, world.map.height - 1);
|
||||
--
|
||||
world.draw;
|
||||
--
|
||||
@ -171,7 +171,7 @@ begin
|
||||
--
|
||||
--~ui.draw_fill_bar (64, core.window_height - 56, 320, 0.7);
|
||||
--
|
||||
chad.draw_pepe;
|
||||
chad.draw_alice;
|
||||
--
|
||||
ui.synchronize;
|
||||
--
|
||||
|
@ -8,55 +8,6 @@ package body world is
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
type landmark_index is (
|
||||
dead_tree, mossy_rock, palm_tree, pine_tree, reeds, rock, snowed_pine_tree, snowed_rock, spiky_rock
|
||||
);
|
||||
|
||||
type landmark_trait is record
|
||||
spawn : biome;
|
||||
clip : boolean;
|
||||
frames : integer;
|
||||
end record;
|
||||
|
||||
type landmark_value is record
|
||||
index : landmark_index;
|
||||
x, y : integer;
|
||||
end record;
|
||||
|
||||
type tile_array is array (natural range <>, natural range <>) of integer;
|
||||
type landmark_array is array (natural range <>) of landmark_value;
|
||||
|
||||
type information is record
|
||||
kind : biome;
|
||||
width : natural;
|
||||
height : natural;
|
||||
tiles : access tile_array;
|
||||
landmarks : access landmark_array;
|
||||
end record;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
map : information;
|
||||
|
||||
tiles : core.sprite;
|
||||
landmarks : array (landmark_index) of core.sprite;
|
||||
|
||||
landmark_limit : constant integer := 120;
|
||||
|
||||
trait : constant array (landmark_index) of landmark_trait := (
|
||||
dead_tree => (ash, true, 1),
|
||||
mossy_rock => (swamp, true, 1),
|
||||
palm_tree => (sand, true, 4),
|
||||
pine_tree => (grass, true, 4),
|
||||
reeds => (swamp, false, 4),
|
||||
rock => (sand, true, 1),
|
||||
snowed_pine_tree => (snow, true, 4),
|
||||
snowed_rock => (snow, true, 1),
|
||||
spiky_rock => (ash, true, 1)
|
||||
);
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure configure is
|
||||
begin
|
||||
core.echo (core.comment, "Configuring world components...");
|
||||
@ -85,7 +36,7 @@ package body world is
|
||||
map.kind := index;
|
||||
map.width := width;
|
||||
map.height := height;
|
||||
map.tiles := new tile_array (0 .. width - 1, 0 .. height - 1);
|
||||
map.tiles := new tile_array (0 .. map.width - 1, 0 .. map.height - 1);
|
||||
map.landmarks := new landmark_array (1 .. landmark_limit);
|
||||
--
|
||||
for x in 0 .. width - 1 loop
|
||||
@ -96,8 +47,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.random (0, width - 1);
|
||||
map.landmarks (index).y := core.random (0, height - 1);
|
||||
map.landmarks (index).x := core.random (0, map.width - 1);
|
||||
map.landmarks (index).y := core.random (0, map.height - 1);
|
||||
end loop;
|
||||
--
|
||||
core.echo (core.success, "Finished procedurally generating new map.");
|
||||
@ -110,34 +61,34 @@ package body world is
|
||||
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));
|
||||
render : core.vector := (map.width - 1,
|
||||
map.height - 1);
|
||||
begin
|
||||
for move_y in 0 .. render.y loop
|
||||
--~exit when core.camera.y + move_y > render.y;
|
||||
for vertical in 0 .. map.height - 1 loop
|
||||
exit when offset.y + (vertical - core.camera.y) * core.base * core.zoom > core.window_height;
|
||||
--
|
||||
for move_x in 0 .. render.x loop
|
||||
--~exit when core.camera.x + move_x > render.x;
|
||||
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 ((core.camera.x + move_x) mod width,
|
||||
(core.camera.y + move_y) mod height);
|
||||
--~v := core.base * map.tiles ((horizontal - core.camera.x) mod map.width, (vertical - core.camera.y) mod map.height);
|
||||
v := core.base * map.tiles (horizontal, vertical);
|
||||
--
|
||||
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,
|
||||
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);
|
||||
--
|
||||
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 + 1) * 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 + 1) * core.base * core.zoom
|
||||
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 and not ui.prioritize then
|
||||
core.camera.x := move_x;
|
||||
core.camera.y := move_y;
|
||||
core.camera.x := horizontal;
|
||||
core.camera.y := vertical;
|
||||
core.cursor_mode := 0;
|
||||
end if;
|
||||
end loop;
|
||||
@ -168,11 +119,6 @@ package body world is
|
||||
--~end loop;
|
||||
--~end draw;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
function width return integer is begin return map.width; end width;
|
||||
function height return integer is begin return map.height; end height;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
end world;
|
||||
|
@ -14,15 +14,61 @@ package world is
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
type landmark_index is (
|
||||
dead_tree, mossy_rock, palm_tree, pine_tree, reeds, rock, snowed_pine_tree, snowed_rock, spiky_rock
|
||||
);
|
||||
|
||||
type landmark_trait is record
|
||||
spawn : biome;
|
||||
clip : boolean;
|
||||
frames : integer;
|
||||
end record;
|
||||
|
||||
type landmark_value is record
|
||||
index : landmark_index;
|
||||
x, y : integer;
|
||||
end record;
|
||||
|
||||
type tile_array is array (natural range <>, natural range <>) of integer;
|
||||
type landmark_array is array (natural range <>) of landmark_value;
|
||||
|
||||
type information is record
|
||||
kind : biome;
|
||||
width : natural;
|
||||
height : natural;
|
||||
tiles : access tile_array;
|
||||
landmarks : access landmark_array;
|
||||
end record;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
tiles : core.sprite;
|
||||
landmarks : array (landmark_index) of core.sprite;
|
||||
|
||||
landmark_limit : constant integer := 120;
|
||||
|
||||
trait : constant array (landmark_index) of landmark_trait := (
|
||||
dead_tree => (ash, true, 1),
|
||||
mossy_rock => (swamp, true, 1),
|
||||
palm_tree => (sand, true, 4),
|
||||
pine_tree => (grass, true, 4),
|
||||
reeds => (swamp, false, 4),
|
||||
rock => (sand, true, 1),
|
||||
snowed_pine_tree => (snow, true, 4),
|
||||
snowed_rock => (snow, true, 1),
|
||||
spiky_rock => (ash, true, 1)
|
||||
);
|
||||
|
||||
map : information;
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
|
||||
procedure configure;
|
||||
|
||||
procedure make (index : in biome; width, height : in natural);
|
||||
|
||||
procedure draw;
|
||||
|
||||
function width return integer;
|
||||
function height return integer;
|
||||
|
||||
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
end world;
|
||||
|
Loading…
Reference in New Issue
Block a user