From 9e137a333caa24ecac00a1db6851ff2efde41815 Mon Sep 17 00:00:00 2001 From: Lerking Date: Tue, 15 Apr 2025 22:17:24 +0200 Subject: [PATCH] Update pman.py --- pman.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/pman.py b/pman.py index c8e2cfb..e39e877 100644 --- a/pman.py +++ b/pman.py @@ -4,7 +4,7 @@ from actors.pacman import ActorPacman from labyrinth import Labyrinth from actors.ghosts import Blinky, Pinky, Inky, Clyde # adjust import path as needed -__version__ = "0.2.0" +__version__ = "0.2.1" def spawn_ghosts(center_position): @@ -26,6 +26,30 @@ def spawn_ghosts(center_position): return pygame.sprite.Group(blinky, pinky, inky, clyde) +def place_pills(maze, spacing=16): + pills = pygame.sprite.Group() + height = len(maze) + width = len(maze[0]) + + # Normal pills + for y in range(height): + for x in range(width): + if maze[y][x] == 0: # assuming 0 is path + if x % spacing == 0 and y % spacing == 0: + pills.add(NormalPill(x * spacing + spacing // 2, y * spacing + spacing // 2)) + + # Power pills in 4 corners + corners = [ + (1, 1), + (1, width - 2), + (height - 2, 1), + (height - 2, width - 2) + ] + for cy, cx in corners: + pills.add(PowerPill(cx * spacing + spacing // 2, cy * spacing + spacing // 2)) + + return pills + def main() -> None: pygame.init() screen_width, screen_height = 800, 800