Update pman.py

This commit is contained in:
2025-04-15 22:17:24 +02:00
parent b3e48c4039
commit 9e137a333c

26
pman.py
View File

@@ -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