Added HUD with lives and level indicators. /JL

This commit is contained in:
2025-04-17 22:29:00 +02:00
parent 21870930ef
commit ffa7ba0db3
6 changed files with 96 additions and 171 deletions

View File

@@ -35,21 +35,21 @@ class Maze:
elif char == "*":
self.power_pellets.add((x, y))
elif char == "P":
self.pacman_start = (x * TILE_SIZE + TILE_SIZE // 2, y * TILE_SIZE + TILE_SIZE // 2)
self.pacman_start = (x * TILE_SIZE + TILE_SIZE // 2, y * TILE_SIZE + TILE_SIZE // 2 + 32)
def draw(self, screen):
for y, row in enumerate(self.layout):
for x, char in enumerate(row):
rect = pygame.Rect(x * TILE_SIZE, y * TILE_SIZE, TILE_SIZE, TILE_SIZE)
rect = pygame.Rect(x * TILE_SIZE, y * TILE_SIZE + 32, TILE_SIZE, TILE_SIZE)
if char == "W":
pygame.draw.rect(screen, COLOR_WALL, rect)
# Draw dots
for (x, y) in self.dots:
center = (x * TILE_SIZE + TILE_SIZE // 2, y * TILE_SIZE + TILE_SIZE // 2)
center = (x * TILE_SIZE + TILE_SIZE // 2, y * TILE_SIZE + TILE_SIZE // 2 + 32)
pygame.draw.circle(screen, COLOR_DOT, center, 2)
# Draw power pellets
for (x, y) in self.power_pellets:
center = (x * TILE_SIZE + TILE_SIZE // 2, y * TILE_SIZE + TILE_SIZE // 2)
center = (x * TILE_SIZE + TILE_SIZE // 2, y * TILE_SIZE + TILE_SIZE // 2 + 32)
pygame.draw.circle(screen, COLOR_POWER, center, 5)
def tile_at(self, x, y):