Minor changes yet again, UI and World refactoring in progress...

This commit is contained in:
Ognjen Milan Robovic 2024-04-27 03:49:02 -04:00
parent 2f62c204bf
commit a02d7bdbcf
6 changed files with 38 additions and 63 deletions

View File

@ -176,7 +176,7 @@ package body core is
--
ray.draw_texture (data => texture_array (data.index),
uv => (float ((animation_time mod data.frames) * u), float (v), float (resize.x), float (resize.y)),
view => (float (x), float (y), float (resize.x) * zoom, float (resize.y) * zoom));
view => (float (x), float (y), float (resize.x) * float (zoom), float (resize.y) * float (zoom)));
end draw;
------------------------------------------------------------------------------------------

View File

@ -68,7 +68,7 @@ package core is
global_time : natural := 0;
gameplay_time : natural := 0;
animation_time : natural := 0;
zoom : float := 2.0;
zoom : natural := 2;
text_box : text_box_data;

View File

@ -10,11 +10,12 @@ procedure main is
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
side_panel : integer := 480;
preview_x : integer := 24;
preview_y : integer := 24;
preview_width : integer := 0;
preview_height : integer := 0;
side_panel : integer := 480;
preview_x : integer := 64;
preview_y : integer := 64;
preview_width : integer := 0;
preview_height : integer := 0;
text_box_height : integer := 32;
player : chad.information := chad.trait (chad.ognjen);
@ -128,8 +129,8 @@ begin
world.make (world.ash, 120, 100);
preview_width := core.window_width - side_panel;
preview_height := core.window_height;
preview_width := core.window_width - side_panel;
preview_height := core.window_height - text_box_height;
core.dash;
core.echo (core.success, "Successfully initialized game data, entering main gameplay loop.");
@ -147,14 +148,10 @@ begin
core.camera.x := core.clip (core.camera.x, 0, world.width - preview_width / core.base);
core.camera.y := core.clip (core.camera.y, 0, world.height - preview_height / core.base);
--
world.draw (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y - 32);
world.draw;
--
--~core.draw_central_grid (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y);
--~core.draw_squared_grid (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y);
--~core.draw_hexagon_grid (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y);
--
ui.draw_menu (0, 0, preview_width, preview_height - 32, false);
ui.draw_tiny_menu (preview_width, 0, side_panel, preview_height - 32, true);
ui.draw_menu (0, 0, preview_width, preview_height, false);
ui.draw_tiny_menu (preview_width, 0, side_panel, preview_height, true);
--
ui.draw_state_box (preview_width + 32, 32);
--
@ -165,9 +162,7 @@ begin
--
menu_render;
--
ui.write (menu_count'image, 16, 16);
--
ui.draw_text_box (0, core.window_height - 32, core.window_width, 32);
ui.draw_text_box (0, core.window_height - text_box_height, core.window_width, text_box_height);
end loop gameplay;
------------------------------------------------------------------------------------------

View File

@ -25,18 +25,18 @@ package body ui is
procedure draw (index : in enumeration; x, y : in integer) is
begin
core.zoom := 1.0;
core.zoom := 1;
core.draw (sprite (active, index), x, y);
core.zoom := 2.0;
core.zoom := 2;
end draw;
------------------------------------------------------------------------------------------
procedure crop (index : in enumeration; x, y, u, v, width, height : in integer) is
begin
core.zoom := 1.0;
core.zoom := 1;
core.draw (sprite (active, index), x, y, u, v, width, height);
core.zoom := 2.0;
core.zoom := 2;
end crop;
------------------------------------------------------------------------------------------
@ -117,9 +117,9 @@ package body ui is
draw (icon, x, y);
select_text_box (description, x, y, core.icon, core.icon);
--
core.zoom := 1.0;
core.zoom := 1;
core.draw (data, x, y);
core.zoom := 2.0;
core.zoom := 2;
--
end draw_icon;

View File

@ -27,8 +27,7 @@ package body world is
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
type information is record
terrain : biome;
width : natural;
height : natural;
@ -87,19 +86,19 @@ package body world is
map.terrain := index;
map.width := width;
map.height := height;
map.tiles := new tile_array (1 .. width, 1 .. height);
map.tiles := new tile_array (0 .. width - 1, 0 .. height - 1);
map.landmarks := new landmark_array (1 .. landmark_limit);
--
for x in 1 .. width loop
for y in 1 .. height loop
for x in 0 .. width - 1 loop
for y in 0 .. height - 1 loop
map.tiles (x, y) := (x * x + x * y + y * y) mod 24;
end loop;
end loop;
--
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, 12);
map.landmarks (index).y := core.base * core.random (1, 12);
map.landmarks (index).x := core.base * core.random (1, 24);
map.landmarks (index).y := core.base * core.random (1, 24);
end loop;
--
core.echo (core.success, "Finished procedurally generating new map.");
@ -107,43 +106,24 @@ package body world is
------------------------------------------------------------------------------------------
procedure draw (x, y, width, height : in integer) is
crop_width : integer := width mod core.base;
crop_height : integer := height mod core.base;
u, v : integer;
procedure draw is
u, v : integer;
begin
for move_y in 1 .. height / core.base loop
for move_x in 1 .. width / core.base loop
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.terrain) * 4;
v := core.base * map.tiles (core.camera.x + move_x, core.camera.y + move_y);
--
core.draw (tiles, x + move_x * core.base, y + move_y * core.base, u, v, core.base, core.base);
core.draw (tiles, (move_x - 1) * core.base * core.zoom, (move_y - 1) * core.base * core.zoom, u, v, core.base, core.base);
end loop;
--
u := core.base * biome'pos (map.terrain) * 4;
v := core.base * map.tiles (width / core.base, core.camera.y + move_y);
--
core.draw (tiles, x + width - crop_width, y + move_y * core.base, u, v, crop_width, core.base);
end loop;
--
for move_x in 1 .. width / core.base loop
u := core.base * biome'pos (map.terrain) * 4;
v := core.base * map.tiles (core.camera.x + move_x, height / core.base);
--
core.draw (tiles, x + move_x * core.base, y + height - crop_height, u, v, core.base, crop_height);
end loop;
--
u := core.base * biome'pos (map.terrain) * 4;
v := core.base * map.tiles (width / core.base, height / core.base);
--
core.draw (tiles, x + width - crop_width, y + height - crop_height, u, v, crop_width, crop_height);
--
for index in 1 .. landmark_limit loop
core.draw (landmarks (map.landmarks (index).index),
map.landmarks (index).x - core.camera.x * core.base,
map.landmarks (index).y - core.camera.y * core.base,
x, y, width, height);
end loop;
--~for index in 1 .. landmark_limit loop
--~core.draw (landmarks (map.landmarks (index).index),
--~map.landmarks (index).x - core.camera.x * core.base,
--~map.landmarks (index).y - core.camera.y * core.base,
--~x, y, core.base, core.base);
--~end loop;
end draw;
------------------------------------------------------------------------------------------

View File

@ -18,7 +18,7 @@ package world is
procedure make (index : in biome; width, height : in natural);
procedure draw (x, y, width, height : in integer);
procedure draw;
function width return integer;
function height return integer;