From 7319d261299dec15c6036bba0ec52251ec2c9aec Mon Sep 17 00:00:00 2001 From: rene Date: Sun, 29 Mar 2026 09:26:18 +0200 Subject: [PATCH] fix whale direction and populate fish on-screen at startup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Whale body/spout-alignment logic was inverted (not going_right → wrong direction). Initial fish population now starts distributed on-screen instead of all off-screen edges, so the aquarium is immediately filled. --- asciiquarium_ng.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/asciiquarium_ng.py b/asciiquarium_ng.py index b74e7b0..aa3edfe 100755 --- a/asciiquarium_ng.py +++ b/asciiquarium_ng.py @@ -594,15 +594,23 @@ class Aquarium: if going_right: shape = sr mask = _rand_color(mr) - x = 1 - max(len(l) for l in shape) + x_offscreen = 1 - max(len(l) for l in shape) else: shape = sl mask = _rand_color(ml) - x = self.cols - 2 + x_offscreen = self.cols - 2 height = len(shape) + width = max(len(l) for l in shape) y = random.randint(9, max(10, self.rows - height)) + # Initial population (dead=None): start already on-screen so the + # aquarium is immediately populated. Respawned fish enter from edges. + if dead is None: + x = random.randint(0, max(0, self.cols - width)) + else: + x = x_offscreen + def on_death(fish, aq): if random.random() < 0.03: aq.add_bubble(fish) @@ -806,9 +814,9 @@ BBBB BBBBB going_right = random.random() < 0.5 speed = 1.0 * (1 if going_right else -1) - spout_align = 11 if not going_right else 1 - body_str = body_r if not going_right else body_l - mask_str = mask_r_str if not going_right else mask_l_str + spout_align = 11 if going_right else 1 + body_str = body_r if going_right else body_l + mask_str = mask_r_str if going_right else mask_l_str x = -18 if going_right else self.cols - 2 frames, masks = [], []