Major changes done, now grinding code style...

This commit is contained in:
Ognjen Milan Robovic 2024-04-27 07:03:40 -04:00
parent a02d7bdbcf
commit ac2516439d
2 changed files with 37 additions and 37 deletions

View File

@ -119,13 +119,15 @@ package body core is
--
texture_count := texture_count + 1;
this.index := texture_count - 1;
this.width := texture_array (this.index).width / states;
this.height := texture_array (this.index).height / frames;
this.width := texture_array (this.index).width / frames;
this.height := texture_array (this.index).height / states;
this.frames := frames;
this.states := states;
--
if this.width = 0 or this.height = 0 then
echo (failure, file_path);
echo (failure, "Sprite not imported: " & file_path);
else
echo (import, this.index'image & file_path & this.frames'image & this.states'image & this.width'image & this.height'image);
end if;
--
return this;
@ -171,12 +173,12 @@ package body core is
state : in integer := 0) is
resize : vector := (0, 0);
begin
resize.x := (if width = 0 then texture_array (data.index).width else width);
resize.y := (if height = 0 then texture_array (data.index).height else height);
resize.x := (if width = 0 then data.width else width);
resize.y := (if height = 0 then data.height else height);
--
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) * float (zoom), float (resize.y) * float (zoom)));
ray.draw_texture (data => texture_array (data.index),
uv => (float (if u = 0 then (animation_time mod data.frames) * data.width else u), float (v), float (resize.x), float (resize.y)),
view => (float (x), float (y), float (resize.x) * float (zoom), float (resize.y) * float (zoom)));
end draw;
------------------------------------------------------------------------------------------
@ -250,7 +252,7 @@ package body core is
echo (comment, "-- Initializing Raylib audio device data...");
ray.open_audio_device;
--
ray.randomization (25071997);
ray.randomization (19970725);
ray.set_target_fps (60);
--
echo (success, "Initialized core components.");

View File

@ -20,19 +20,18 @@ package body world is
type landmark_value is record
index : landmark_index;
x : integer;
y : integer;
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
terrain : biome;
width : natural;
height : natural;
tiles : access tile_array;
landmarks : access landmark_array;
kind : biome;
width : natural;
height : natural;
tiles : access tile_array;
landmarks : access landmark_array;
end record;
------------------------------------------------------------------------------------------
@ -42,18 +41,18 @@ package body world is
tiles : core.sprite;
landmarks : array (landmark_index) of core.sprite;
landmark_limit : constant integer := 7;
landmark_limit : constant integer := 40;
trait : constant array (landmark_index) of landmark_trait := (
(ash, true, 1),
(swamp, true, 1),
(cave, true, 4),
(grass, true, 4),
(swamp, false, 4),
(cave, true, 1),
(snow, true, 4),
(snow, true, 1),
(ash, true, 1)
dead_tree => (ash, true, 1),
mossy_rock => (swamp, true, 1),
palm_tree => (cave, true, 4),
pine_tree => (grass, true, 4),
reeds => (swamp, false, 4),
rock => (cave, true, 1),
snowed_pine_tree => (snow, true, 4),
snowed_rock => (snow, true, 1),
spiky_rock => (ash, true, 1)
);
------------------------------------------------------------------------------------------
@ -83,7 +82,7 @@ package body world is
core.echo (core.comment, "-- -- Map height :" & height'image);
core.echo (core.comment, "-- -- Landmark count :" & landmark_limit'image);
--
map.terrain := index;
map.kind := index;
map.width := width;
map.height := height;
map.tiles := new tile_array (0 .. width - 1, 0 .. height - 1);
@ -91,14 +90,14 @@ package body world is
--
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) := core.random (0, 23);
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, 24);
map.landmarks (index).y := core.base * core.random (1, 24);
map.landmarks (index).x := core.base * core.random (1, 90);
map.landmarks (index).y := core.base * core.random (1, 60);
end loop;
--
core.echo (core.success, "Finished procedurally generating new map.");
@ -111,19 +110,18 @@ package body world is
begin
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.kind) * 4;
v := core.base * map.tiles (core.camera.x + move_x, core.camera.y + move_y);
--
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;
--
--~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;
for index in 1 .. landmark_limit loop
core.draw (data => landmarks (map.landmarks (index).index),
x => map.landmarks (index).x - core.camera.x * core.base,
y => map.landmarks (index).y - core.camera.y * core.base);
end loop;
end draw;
------------------------------------------------------------------------------------------