fix whale direction and populate fish on-screen at startup
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.
This commit is contained in:
parent
9f3f754921
commit
7319d26129
1 changed files with 13 additions and 5 deletions
|
|
@ -594,15 +594,23 @@ class Aquarium:
|
||||||
if going_right:
|
if going_right:
|
||||||
shape = sr
|
shape = sr
|
||||||
mask = _rand_color(mr)
|
mask = _rand_color(mr)
|
||||||
x = 1 - max(len(l) for l in shape)
|
x_offscreen = 1 - max(len(l) for l in shape)
|
||||||
else:
|
else:
|
||||||
shape = sl
|
shape = sl
|
||||||
mask = _rand_color(ml)
|
mask = _rand_color(ml)
|
||||||
x = self.cols - 2
|
x_offscreen = self.cols - 2
|
||||||
|
|
||||||
height = len(shape)
|
height = len(shape)
|
||||||
|
width = max(len(l) for l in shape)
|
||||||
y = random.randint(9, max(10, self.rows - height))
|
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):
|
def on_death(fish, aq):
|
||||||
if random.random() < 0.03:
|
if random.random() < 0.03:
|
||||||
aq.add_bubble(fish)
|
aq.add_bubble(fish)
|
||||||
|
|
@ -806,9 +814,9 @@ BBBB BBBBB
|
||||||
|
|
||||||
going_right = random.random() < 0.5
|
going_right = random.random() < 0.5
|
||||||
speed = 1.0 * (1 if going_right else -1)
|
speed = 1.0 * (1 if going_right else -1)
|
||||||
spout_align = 11 if not going_right else 1
|
spout_align = 11 if going_right else 1
|
||||||
body_str = body_r if not going_right else body_l
|
body_str = body_r if going_right else body_l
|
||||||
mask_str = mask_r_str if not going_right else mask_l_str
|
mask_str = mask_r_str if going_right else mask_l_str
|
||||||
x = -18 if going_right else self.cols - 2
|
x = -18 if going_right else self.cols - 2
|
||||||
|
|
||||||
frames, masks = [], []
|
frames, masks = [], []
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue