From b5b34b4bb9429d739cdeaf88d74fb18f9632e138 Mon Sep 17 00:00:00 2001 From: Ken D'Ambrosio Date: Fri, 5 Jun 2026 08:30:09 -0400 Subject: Remove black sheep feature Co-Authored-By: Claude Sonnet 4.6 --- esheep.py | 65 ++++++++------------------------------------------------------- 1 file changed, 8 insertions(+), 57 deletions(-) diff --git a/esheep.py b/esheep.py index 1ec71a7..cf2d670 100644 --- a/esheep.py +++ b/esheep.py @@ -726,7 +726,6 @@ class SheepOverlay: f"animations: {len(self.anim_defs)}", flush=True) self.cairo_surface = self._pil_to_cairo(self.sprite) - self.dark_surface = self._make_dark_surface(self.sprite) # Patch fall-hard (10) to occasionally boing on landing — 20% chance hard = self.anim_defs.get(10) @@ -747,8 +746,6 @@ class SheepOverlay: # Extra features self._flowers: List[Flower] = [] - self._black_sheep_set: set = set() - self._black_sheep_countdown = random.uniform(180, 300) # seconds self._eat_countdown = random.uniform(30, 90) # seconds self._interact_cooldowns: Dict[Tuple[int,int], float] = {} # ms self._frozen_sheep: Dict[int, float] = {} # id→remaining ms @@ -774,15 +771,6 @@ class SheepOverlay: surf.mark_dirty() return surf - @staticmethod - def _make_dark_surface(img: 'Image.Image') -> cairo.ImageSurface: - """Near-black tinted sprite for the black sheep visitor.""" - import numpy as np - arr = np.array(img, dtype=np.float32) - arr[:, :, :3] *= 0.18 # desaturate to near-black, preserve alpha - from PIL import Image as _Image - return SheepOverlay._pil_to_cairo(_Image.fromarray(arr.astype(np.uint8))) - def _build_window(self): self.win = Gtk.Window(type=Gtk.WindowType.TOPLEVEL) self.win.set_app_paintable(True) @@ -926,22 +914,6 @@ class SheepOverlay: # ── extra features ── - def _spawn_black_sheep(self): - """Spawn a dark-tinted sheep from a random edge doing the blacksheep sequence.""" - from_right = random.random() < 0.5 - anim_id = 28 if from_right else 31 # 28=approach-left, 31=approach-right - sp = SpawnDef( - id=99, probability=100, - x_expr='screenW' if from_right else '0-imageW', - y_expr='screenH-imageH', - next_anim=anim_id, - ) - sheep = Sheep(self.anim_defs, self.tile_w, self.tile_h, - self.screen_w, self.screen_h, sp) - self.sheep_list.append(sheep) - self._black_sheep_set.add(sheep) - print(f"Black sheep enters from the {'right' if from_right else 'left'}!", flush=True) - def _check_interactions(self, dt_ms: float): """Bump and greet walking sheep that get too close.""" busy = {self._drag_sheep} | {u.sheep for u in self.ufos} @@ -959,10 +931,7 @@ class SheepOverlay: hdist = abs(a.x - b.x) overlapping = hdist < self.tile_w * 0.6 and same_level - # One or both sheep is black → skip social interactions - either_black = a in self._black_sheep_set or b in self._black_sheep_set - - if overlapping and not either_black: + if overlapping: # Bump: boing and reverse a.facing_right = not a.facing_right b.facing_right = not b.facing_right @@ -971,7 +940,7 @@ class SheepOverlay: self._interact_cooldowns[key] = 7000.0 print("Sheep bumped into each other!", flush=True) - elif (hdist < self.tile_w * 2.2 and same_level and not either_black + elif (hdist < self.tile_w * 2.2 and same_level and id(a) not in self._frozen_sheep and id(b) not in self._frozen_sheep): # Approaching each other? (each facing toward the other) @@ -1036,7 +1005,6 @@ class SheepOverlay: self._eat_countdown = random.uniform(60, 120) candidates = [s for s in self.sheep_list if s is not self._drag_sheep - and s not in self._black_sheep_set and s.floor_cond == COND_NONE and not any(u.sheep is s for u in self.ufos) and s.anim_id not in (5, 6, 13, 26)] @@ -1049,31 +1017,16 @@ class SheepOverlay: f.tick(dt) self._flowers = [f for f in self._flowers if not f.done] - # ── black sheep ── - self._black_sheep_countdown -= dt / 1000.0 - if self._black_sheep_countdown <= 0: - self._spawn_black_sheep() - self._black_sheep_countdown = random.uniform(180, 360) - # Remove black sheep that have fully faded out (finished anim 34, opacity→0) - gone = [s for s in self._black_sheep_set if s.anim_id == 34 and s.opacity < 0.05] - for s in gone: - self._black_sheep_set.discard(s) - if s in self.sheep_list: - self.sheep_list.remove(s) - print("Black sheep has vanished.", flush=True) - # ── bumps & greetings ── self._check_interactions(dt) # UFO timer self._ufo_countdown -= dt / 1000.0 if self._ufo_countdown <= 0 and self.sheep_list: - candidates = [s for s in self.sheep_list if s not in self._black_sheep_set] - if candidates: - target = random.choice(candidates) - if not any(u.sheep is target for u in self.ufos): - self.ufos.append(UFO(target, self.screen_w, self.screen_h)) - print("UFO abduction started!", flush=True) + target = random.choice(self.sheep_list) + if not any(u.sheep is target for u in self.ufos): + self.ufos.append(UFO(target, self.screen_w, self.screen_h)) + print("UFO abduction started!", flush=True) self._ufo_countdown = self.UFO_INTERVAL_S + random.randint(-20, 30) # Tick UFOs @@ -1098,12 +1051,10 @@ class SheepOverlay: for flower in self._flowers: flower.draw(cr) - # Draw sheep (black sheep use darkened sprite) + # Draw sheep for sheep in self.sheep_list: frame, sx, sy, flip, alpha = sheep.draw_info() - surface = (self.dark_surface if sheep in self._black_sheep_set - else self.cairo_surface) - draw_frame(cr, surface, + draw_frame(cr, self.cairo_surface, self.tile_w, self.tile_h, self.tiles_x, frame, sx, sy, flip, alpha) -- cgit v1.2.3