From 2436aebe221fbfc0eb099d0f21d1b71f0cc25943 Mon Sep 17 00:00:00 2001 From: xolatile Date: Sat, 25 May 2024 13:10:34 -0400 Subject: [PATCH] Happy with lake generation... --- source/world.adb | 46 +++++++++------------------------------------- 1 file changed, 9 insertions(+), 37 deletions(-) diff --git a/source/world.adb b/source/world.adb index a48497e..bd0e566 100644 --- a/source/world.adb +++ b/source/world.adb @@ -112,47 +112,19 @@ package body world is for this in 1 .. lake_count loop declare lake_x : integer := 0; lake_y : integer := 0; - factor : boolean := false; + starts : integer := 0; + length : integer := 0; begin lake_x := core.random (2 * lake_reach, map.width - 2 * lake_reach - 1); lake_y := core.random (2 * lake_reach, map.height - 2 * lake_reach - 1); -- - for x in -lake_reach .. lake_reach loop - for y in -lake_reach .. lake_reach loop - factor := core.random (0, abs (x * y)) > abs (x * y) / 6; - -- - map.tiles (lake_x + x, lake_y + y) := (if factor then core.random (0, 17) else core.random (18, 23)); - end loop; - end loop; - -- - for x in -lake_reach .. lake_reach loop - for y in -lake_reach .. lake_reach loop - for again in 0 .. 3 loop - if map.tiles (lake_x + x, lake_y + y) < 18 then - if boolean'pos (map.tiles (lake_x + x - 1, lake_y + y - 1) > 17) + - boolean'pos (map.tiles (lake_x + x - 1, lake_y + y ) > 17) + - boolean'pos (map.tiles (lake_x + x - 1, lake_y + y + 1) > 17) + - boolean'pos (map.tiles (lake_x + x, lake_y + y - 1) > 17) + - boolean'pos (map.tiles (lake_x + x, lake_y + y ) > 17) + - boolean'pos (map.tiles (lake_x + x, lake_y + y + 1) > 17) + - boolean'pos (map.tiles (lake_x + x + 1, lake_y + y - 1) > 17) + - boolean'pos (map.tiles (lake_x + x + 1, lake_y + y ) > 17) + - boolean'pos (map.tiles (lake_x + x + 1, lake_y + y + 1) > 17) > 3 then - map.tiles (lake_x + x, lake_y + y) := core.random (18, 23); - end if; - --~else - --~if boolean'pos (map.tiles (lake_x + x - 1, lake_y + y - 1) < 18) + - --~boolean'pos (map.tiles (lake_x + x - 1, lake_y + y ) < 18) + - --~boolean'pos (map.tiles (lake_x + x - 1, lake_y + y + 1) < 18) + - --~boolean'pos (map.tiles (lake_x + x, lake_y + y - 1) < 18) + - --~boolean'pos (map.tiles (lake_x + x, lake_y + y ) < 18) + - --~boolean'pos (map.tiles (lake_x + x, lake_y + y + 1) < 18) + - --~boolean'pos (map.tiles (lake_x + x + 1, lake_y + y - 1) < 18) + - --~boolean'pos (map.tiles (lake_x + x + 1, lake_y + y ) < 18) + - --~boolean'pos (map.tiles (lake_x + x + 1, lake_y + y + 1) < 18) > 3 then - --~map.tiles (lake_x + x, lake_y + y) := core.random (0, 17); - --~end if; - end if; + for x in -lake_reach / 2 .. lake_reach / 2 loop + starts := core.random (0, abs x); + length := core.random (lake_reach / 2, lake_reach - starts); + -- + for repeat in 0 .. 1 loop + for y in starts .. starts + length loop + map.tiles (lake_x + 2 * x + repeat, lake_y + y) := core.random (18, 23); end loop; end loop; end loop;