Parcourir la source

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

master
Ognjen Milan Robovic il y a 3 semaines
Parent
révision
a02d7bdbcf
6 fichiers modifiés avec 38 ajouts et 63 suppressions
  1. +1
    -1
      source/core.adb
  2. +1
    -1
      source/core.ads
  3. +12
    -17
      source/main.adb
  4. +6
    -6
      source/ui.adb
  5. +17
    -37
      source/world.adb
  6. +1
    -1
      source/world.ads

+ 1
- 1
source/core.adb Voir le fichier

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


------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------


+ 1
- 1
source/core.ads Voir le fichier

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


text_box : text_box_data; text_box : text_box_data;




+ 12
- 17
source/main.adb Voir le fichier

@@ -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); player : chad.information := chad.trait (chad.ognjen);


@@ -128,8 +129,8 @@ begin


world.make (world.ash, 120, 100); 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.dash;
core.echo (core.success, "Successfully initialized game data, entering main gameplay loop."); 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.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); 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); ui.draw_state_box (preview_width + 32, 32);
-- --
@@ -165,9 +162,7 @@ begin
-- --
menu_render; 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; end loop gameplay;


------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------


+ 6
- 6
source/ui.adb Voir le fichier

@@ -25,18 +25,18 @@ package body ui is


procedure draw (index : in enumeration; x, y : in integer) is procedure draw (index : in enumeration; x, y : in integer) is
begin begin
core.zoom := 1.0;
core.zoom := 1;
core.draw (sprite (active, index), x, y); core.draw (sprite (active, index), x, y);
core.zoom := 2.0;
core.zoom := 2;
end draw; end draw;


------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------


procedure crop (index : in enumeration; x, y, u, v, width, height : in integer) is procedure crop (index : in enumeration; x, y, u, v, width, height : in integer) is
begin begin
core.zoom := 1.0;
core.zoom := 1;
core.draw (sprite (active, index), x, y, u, v, width, height); core.draw (sprite (active, index), x, y, u, v, width, height);
core.zoom := 2.0;
core.zoom := 2;
end crop; end crop;


------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------
@@ -117,9 +117,9 @@ package body ui is
draw (icon, x, y); draw (icon, x, y);
select_text_box (description, x, y, core.icon, core.icon); select_text_box (description, x, y, core.icon, core.icon);
-- --
core.zoom := 1.0;
core.zoom := 1;
core.draw (data, x, y); core.draw (data, x, y);
core.zoom := 2.0;
core.zoom := 2;
-- --
end draw_icon; end draw_icon;




+ 17
- 37
source/world.adb Voir le fichier

@@ -27,8 +27,7 @@ package body world is
type tile_array is array (natural range <>, natural range <>) of integer; type tile_array is array (natural range <>, natural range <>) of integer;
type landmark_array is array (natural range <>) of landmark_value; type landmark_array is array (natural range <>) of landmark_value;


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


------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------


+ 1
- 1
source/world.ads Voir le fichier

@@ -18,7 +18,7 @@ package world is


procedure make (index : in biome; width, height : in natural); procedure make (index : in biome; width, height : in natural);


procedure draw (x, y, width, height : in integer);
procedure draw;


function width return integer; function width return integer;
function height return integer; function height return integer;


Chargement…
Annuler
Enregistrer