Added maze loading. /JL

This commit is contained in:
2025-04-17 21:40:49 +02:00
parent fdd3ce1255
commit 21870930ef
8 changed files with 158 additions and 37 deletions

View File

@@ -23,7 +23,7 @@ class PivotWall:
(x + dx - dy * self.thickness / self.length, y + dy + dx * self.thickness / self.length),
]
pygame.draw.polygon(self.screen, Colors.Cyan, points)
pygame.draw.polygon(self.screen, Colors.Cyan.value, points)
def rotate(self, delta_angle):
self.angle = (self.angle + delta_angle) % 360
@@ -42,15 +42,15 @@ class GhostHome:
r = self.rect
t = self.wall_thickness
pygame.draw.rect(self.screen, Colors.Magenta, (r.left, r.top + t, t, r.height -t))
pygame.draw.rect(self.screen, Colors.Magenta, (r.right - t, r.top + t, t, r.height -t))
pygame.draw.rect(self.screen, Colors.Magenta, (r.left, r.bottom - t, r.width, t))
pygame.draw.rect(self.screen, Colors.Magenta.value, (r.left, r.top + t, t, r.height -t))
pygame.draw.rect(self.screen, Colors.Magenta.value, (r.right - t, r.top + t, t, r.height -t))
pygame.draw.rect(self.screen, Colors.Magenta.value, (r.left, r.bottom - t, r.width, t))
gap = 40
gap_x1 = r.centerx - gap // 2
gap_x2 = r.centerx + gap // 2
pygame.draw.rect(self.screen, Colors.Magenta, (r.left, r.top, gap_x1 - r.left, t))
pygame.draw.rect(self.screen, Colors.Magenta, (gap_x2, r.top, r.right - gap_x2, t))
pygame.draw.rect(self.screen, Colors.Magenta.value, (r.left, r.top, gap_x1 - r.left, t))
pygame.draw.rect(self.screen, Colors.Magenta.value, (gap_x2, r.top, r.right - gap_x2, t))
class Labyrinth:
def __init__(self, screen, width, height, wall_thickness=20):
@@ -72,15 +72,15 @@ class Labyrinth:
mid_x = self.width // 2
mid_y = self.height // 2
pygame.draw.rect(self.screen, Colors.Blue, (0, 0, mid_x - 50, w))
pygame.draw.rect(self.screen, Colors.Blue, (mid_x + 50, self.width - (mid_x + 50), w))
pygame.draw.rect(self.screen, Colors.Blue, (0, self.height - w, mid_x - 50, w))
pygame.draw.rect(self.screen, Colors.Blue, (mid_x + 50, self.height - w, self.width - (mid_x + 50), w))
pygame.draw.rect(self.screen, Colors.Blue.value, (0, 0, mid_x - 50, w))
pygame.draw.rect(self.screen, Colors.Blue.value, (mid_x + 50, 0, self.width - (mid_x + 50), w))
pygame.draw.rect(self.screen, Colors.Blue.value, (0, self.height - w, mid_x - 50, w))
pygame.draw.rect(self.screen, Colors.Blue.value, (mid_x + 50, self.height - w, self.width - (mid_x + 50), w))
pygame.draw.rect(self.screen, Colors.Blue, (0, 0, w, mid_y -50))
pygame.draw.rect(self.screen, Colors.Blue, (0, mid_y + 50, w, self.height - (mid_y + 50)))
pygame.draw.rect(self.screen, Colors.Blue, (self.width - w, 0, w, mid_y - 50))
pygame.draw.rect(self.screen, Colors.Blue, (self.width - w, mid_y + 50, w, self.height - (mid_y + 50)))
pygame.draw.rect(self.screen, Colors.Blue.value, (0, 0, w, mid_y -50))
pygame.draw.rect(self.screen, Colors.Blue.value, (0, mid_y + 50, w, self.height - (mid_y + 50)))
pygame.draw.rect(self.screen, Colors.Blue.value, (self.width - w, 0, w, mid_y - 50))
pygame.draw.rect(self.screen, Colors.Blue.value, (self.width - w, mid_y + 50, w, self.height - (mid_y + 50)))
for pivot in self.pivot_walls:
pivot.draw()