From 2f62c204bf24bd9dfc7ef12b32d8cd66cf41cd85 Mon Sep 17 00:00:00 2001 From: xolatile Date: Fri, 26 Apr 2024 19:46:09 -0400 Subject: [PATCH] Minor changes before going to bed... --- source/item.adb | 2 +- source/main.adb | 4 +- source/world.adb | 150 ++++++++++++--------- source/world.ads | 32 +---- sprite/world/landmark/cave/ 0.png | Bin 215 -> 0 bytes sprite/world/landmark/cave/ 1.png | Bin 288 -> 0 bytes .../world/landmark/{ash/ 1.png => dead_tree.png} | Bin .../landmark/{swamp/ 0.png => mossy_rock.png} | Bin .../world/landmark/{sand/ 1.png => palm_tree.png} | Bin .../world/landmark/{grass/ 1.png => pine_tree.png} | Bin sprite/world/landmark/{swamp/ 1.png => reeds.png} | Bin sprite/world/landmark/{grass/ 0.png => rock.png} | Bin sprite/world/landmark/rough/ 0.png | Bin 215 -> 0 bytes sprite/world/landmark/rough/ 1.png | Bin 190 -> 0 bytes sprite/world/landmark/sand/ 0.png | Bin 190 -> 0 bytes .../landmark/{snow/ 1.png => snowed_pine_tree.png} | Bin .../landmark/{snow/ 0.png => snowed_rock.png} | Bin .../world/landmark/{ash/ 0.png => spiky_rock.png} | Bin 18 files changed, 91 insertions(+), 97 deletions(-) delete mode 100644 sprite/world/landmark/cave/ 0.png delete mode 100644 sprite/world/landmark/cave/ 1.png rename sprite/world/landmark/{ash/ 1.png => dead_tree.png} (100%) rename sprite/world/landmark/{swamp/ 0.png => mossy_rock.png} (100%) rename sprite/world/landmark/{sand/ 1.png => palm_tree.png} (100%) rename sprite/world/landmark/{grass/ 1.png => pine_tree.png} (100%) rename sprite/world/landmark/{swamp/ 1.png => reeds.png} (100%) rename sprite/world/landmark/{grass/ 0.png => rock.png} (100%) delete mode 100644 sprite/world/landmark/rough/ 0.png delete mode 100644 sprite/world/landmark/rough/ 1.png delete mode 100644 sprite/world/landmark/sand/ 0.png rename sprite/world/landmark/{snow/ 1.png => snowed_pine_tree.png} (100%) rename sprite/world/landmark/{snow/ 0.png => snowed_rock.png} (100%) rename sprite/world/landmark/{ash/ 0.png => spiky_rock.png} (100%) diff --git a/source/item.adb b/source/item.adb index 00d852a..fdbd320 100644 --- a/source/item.adb +++ b/source/item.adb @@ -22,7 +22,7 @@ package body item is folder : constant string := core.lowercase (slot'image (trait (index).kind)); file : constant string := core.lowercase (enumeration'image (index)); begin - sprite (index) := core.import_sprite ("./sprite/item/" & folder & "/" & file & ".png", 1, 1); + sprite (index) := core.import_sprite ("./sprite/item/" & folder & "/" & file & ".png", 4, 6); end; end loop; end configure; diff --git a/source/main.adb b/source/main.adb index 2f4ccc9..7d90767 100644 --- a/source/main.adb +++ b/source/main.adb @@ -144,8 +144,8 @@ begin -- ui.active := (if core.cursor_mode = 3 then ui.default else ui.steam); -- - core.camera.x := core.clip (core.camera.x, 0, world.map.width - preview_width / core.base); - core.camera.y := core.clip (core.camera.y, 0, world.map.height - preview_height / 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); -- world.draw (preview_x, preview_y, preview_width - 2 * preview_x, preview_height - 2 * preview_y - 32); -- diff --git a/source/world.adb b/source/world.adb index 6f9dc87..930d855 100644 --- a/source/world.adb +++ b/source/world.adb @@ -8,24 +8,54 @@ package body world is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - type sprite_array is array (natural range <>) of core.sprite; + type landmark_index is ( + dead_tree, mossy_rock, palm_tree, pine_tree, reeds, rock, snowed_pine_tree, snowed_rock, spiky_rock + ); - type world_array is array (natural range <>) of access information; + type landmark_trait is record + spawn : biome; + clip : boolean; + frames : integer; + end record; - type limit_array is array (enumeration) of integer; + type landmark_value is record + index : landmark_index; + x : integer; + y : integer; + end record; - type landmark_sprite_array is array (enumeration) of access sprite_array; + 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; + end record; ------------------------------------------------------------------------------------------ - blocks : core.sprite; - landmarks : landmark_sprite_array := (others => null); + map : information; - limit : constant limit_array := (2, 2, 2, 2, 2, 2); + tiles : core.sprite; + landmarks : array (landmark_index) of core.sprite; - landmark_limit : constant integer := 140; - construction_limit : constant integer := 40; - item_limit : constant integer := 40; + landmark_limit : constant integer := 7; + + 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) + ); ------------------------------------------------------------------------------------------ @@ -33,27 +63,19 @@ package body world is begin core.echo (core.comment, "Configuring world components..."); -- - blocks := core.import_sprite ("./sprite/world/terrain/terrain.png", 1, 1); + tiles := core.import_sprite ("./sprite/world/terrain/terrain.png", 1, 1); -- - for index in enumeration - loop - landmarks (index) := new sprite_array (0 .. limit (index) - 1); - -- - for value in 0 .. limit (index) - 1 - loop - declare - folder : constant string := core.lowercase (enumeration'image (index)); - file : constant string := value'image; - begin - landmarks (index) (value) := core.import_sprite ("./sprite/world/landmark/" & folder & "/" & file & ".png", 1, 1); - end; - end loop; + for index in landmark_index loop + declare file : constant string := core.lowercase (index'image); + begin + landmarks (index) := core.import_sprite ("./sprite/world/landmark/" & file & ".png", trait (index).frames, 1); + end; end loop; end configure; ------------------------------------------------------------------------------------------ - procedure make (index : in enumeration; width, height : in natural) is + procedure make (index : in biome; width, height : in natural) is begin core.echo (core.comment, "-- Procedurally generating new map..."); -- @@ -61,30 +83,23 @@ package body world is core.echo (core.comment, "-- -- Map width :" & width'image); core.echo (core.comment, "-- -- Map height :" & height'image); core.echo (core.comment, "-- -- Landmark count :" & landmark_limit'image); - core.echo (core.comment, "-- -- Construction count :" & construction_limit'image); - core.echo (core.comment, "-- -- Item count :" & item_limit'image); -- - map.terrain := index; - map.width := width; - map.height := height; - map.block := new block_array (0 .. width - 1, 0 .. height - 1); - map.landmark := new entity_array (0 .. landmark_limit); - map.construction := new entity_array (0 .. construction_limit); - map.item := new entity_array (0 .. item_limit); + map.terrain := index; + map.width := width; + map.height := height; + map.tiles := new tile_array (1 .. width, 1 .. height); + map.landmarks := new landmark_array (1 .. landmark_limit); -- - for x in 0 .. width - 1 - loop - for y in 0 .. height - 1 - loop - map.block (x, y) := (x * x + x * y + y * y) mod 24; + for x in 1 .. width loop + for y in 1 .. height loop + map.tiles (x, y) := (x * x + x * y + y * y) mod 24; end loop; end loop; -- - for object in 0 .. landmark_limit - loop - map.landmark (object).index := core.random (0, limit (index) - 1); - map.landmark (object).x := core.base * core.random (1, map.width - 1); - map.landmark (object).y := core.base * core.random (1, map.height - 1); + 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); end loop; -- core.echo (core.success, "Finished procedurally generating new map."); @@ -97,44 +112,45 @@ package body world is crop_height : integer := height mod core.base; u, v : integer; begin - for move_y in 0 .. height / core.base - 1 - loop - for move_x in 0 .. width / core.base - 1 - loop - u := core.base * enumeration'pos (map.terrain) * 4; - v := core.base * map.block (core.camera.x + move_x, core.camera.y + move_y); + for move_y in 1 .. height / core.base 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, core.camera.y + move_y); -- - core.draw (blocks, x + move_x * core.base, y + move_y * core.base, u, v, core.base, core.base); + core.draw (tiles, x + move_x * core.base, y + move_y * core.base, u, v, core.base, core.base); end loop; -- - u := core.base * enumeration'pos (map.terrain) * 4; - v := core.base * map.block (width / core.base, core.camera.y + move_y); + u := core.base * biome'pos (map.terrain) * 4; + v := core.base * map.tiles (width / core.base, core.camera.y + move_y); -- - core.draw (blocks, x + width - crop_width, y + move_y * core.base, u, v, crop_width, core.base); + core.draw (tiles, x + width - crop_width, y + move_y * core.base, u, v, crop_width, core.base); end loop; -- - for move_x in 0 .. width / core.base - 1 - loop - u := core.base * enumeration'pos (map.terrain) * 4; - v := core.base * map.block (core.camera.x + move_x, height / core.base); + 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 (blocks, x + move_x * core.base, y + height - crop_height, u, v, core.base, crop_height); + core.draw (tiles, x + move_x * core.base, y + height - crop_height, u, v, core.base, crop_height); end loop; -- - u := core.base * enumeration'pos (map.terrain) * 4; - v := core.base * map.block (width / core.base, height / core.base); + u := core.base * biome'pos (map.terrain) * 4; + v := core.base * map.tiles (width / core.base, height / core.base); -- - core.draw (blocks, x + width - crop_width, y + height - crop_height, u, v, crop_width, crop_height); + core.draw (tiles, x + width - crop_width, y + height - crop_height, u, v, crop_width, crop_height); -- - for object in 0 .. landmark_limit - loop - core.draw (landmarks (map.terrain) (map.landmark (object).index), - map.landmark (object).x - core.camera.x * core.base, - map.landmark (object).y - core.camera.y * core.base, + 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; 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; diff --git a/source/world.ads b/source/world.ads index 35a43e1..70bc882 100644 --- a/source/world.ads +++ b/source/world.ads @@ -8,43 +8,21 @@ package world is ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ - type enumeration is ( + type biome is ( ash, cave, grass, rough, snow, swamp ); ------------------------------------------------------------------------------------------ - type entity is - record - index, x, y : integer; - end record; - - type block_array is array (natural range <>, natural range <>) of integer; - type entity_array is array (natural range <>) of entity; - - type information is - record - terrain : enumeration; - width : natural; - height : natural; - block : access block_array; - landmark : access entity_array; - construction : access entity_array; - item : access entity_array; - end record; - - ------------------------------------------------------------------------------------------ - - map : information; - - ------------------------------------------------------------------------------------------ - procedure configure; - procedure make (index : in enumeration; width, height : in natural); + procedure make (index : in biome; width, height : in natural); procedure draw (x, y, width, height : in integer); + function width return integer; + function height return integer; + ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ end world; diff --git a/sprite/world/landmark/cave/ 0.png b/sprite/world/landmark/cave/ 0.png deleted file mode 100644 index 8eb6345512ece89c77df7ad9e2e4738f731d81ba..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 215 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F3${@^GvDCf{DA?)g z;uvCadT)>;SAzjh_u=VJbgNJATlgP@YV3$tgLu>Rwiv^tzSe%5XV z28E?hm|B;=R8f3s+q`$Cik)}H(HFXF(|4UdkiAXprmo_#A7>6k-Lbs?*2Xx~XhKM& z#>-RcVoWBa2HvF;TOtz}+SXAz?kDIgAX6oaR$ KpUXO@geCxnb52A6 diff --git a/sprite/world/landmark/cave/ 1.png b/sprite/world/landmark/cave/ 1.png deleted file mode 100644 index 94284621101b99248190cfcc466757ed2d52f3b7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 288 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F3${@^GvDCf{D0s=! z#WBRdU8j z9?U;K$;@c&y*|shGjR#b+h4tXQzWnZ_*L!uW#Z2HrRDz*9y}7)v2xml5B*-d!({ub z+#WDb2#@)&CsjBpDXuUmS+GXyB+HQ~8^#~c{XS&1x>V#?O)!p&5bUjy30dU6fYooS iltlCLkl@Fmcg5o`l-QgP*lP#$9fPN;SAzjh_u=VJbgNJATlgP@YV3$tgLu>Rwiv^tzSe%5XV z28E?hm|B;=R8f3s+q`$Cik)}H(HFXF(|4UdkiAXprmo_#A7>6k-Lbs?*2Xx~XhKM& z#>-RcVoWBa2HvF;TOtz}+SXAz?kDIgAX6oaR$ KpUXO@geCxnb52A6 diff --git a/sprite/world/landmark/rough/ 1.png b/sprite/world/landmark/rough/ 1.png deleted file mode 100644 index 1563841a7b5d4127a7bb0426c5d45b034c8da26b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 190 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F3${@^GvDCf{C|Ka> z;uvCa`t8JvoCg$mT>M|Cn9s?+vhJbI%%@?Q^*X&1!(MD>JXlb9JhLHmb%TktLglZx zpyN5l8qaw=85oRbtM5qUx8mJ;P0zE-z;nW%nrSn8+3FuW9h*EeXWM1{>z*bF=LDEqfOa!@y85}Sb4q9e0FjkLi2wiq diff --git a/sprite/world/landmark/sand/ 0.png b/sprite/world/landmark/sand/ 0.png deleted file mode 100644 index 1563841a7b5d4127a7bb0426c5d45b034c8da26b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 190 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9F3${@^GvDCf{C|Ka> z;uvCa`t8JvoCg$mT>M|Cn9s?+vhJbI%%@?Q^*X&1!(MD>JXlb9JhLHmb%TktLglZx zpyN5l8qaw=85oRbtM5qUx8mJ;P0zE-z;nW%nrSn8+3FuW9h*EeXWM1{>z*bF=LDEqfOa!@y85}Sb4q9e0FjkLi2wiq diff --git a/sprite/world/landmark/snow/ 1.png b/sprite/world/landmark/snowed_pine_tree.png similarity index 100% rename from sprite/world/landmark/snow/ 1.png rename to sprite/world/landmark/snowed_pine_tree.png diff --git a/sprite/world/landmark/snow/ 0.png b/sprite/world/landmark/snowed_rock.png similarity index 100% rename from sprite/world/landmark/snow/ 0.png rename to sprite/world/landmark/snowed_rock.png diff --git a/sprite/world/landmark/ash/ 0.png b/sprite/world/landmark/spiky_rock.png similarity index 100% rename from sprite/world/landmark/ash/ 0.png rename to sprite/world/landmark/spiky_rock.png