diff options
Diffstat (limited to 'GameView.py')
| -rw-r--r-- | GameView.py | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/GameView.py b/GameView.py index 50785a7..3b458d8 100644 --- a/GameView.py +++ b/GameView.py @@ -1,6 +1,10 @@ from Game import Game from Box import Box +from Door import Door +from PressurePlate import PressurePlate +from Trail import Trail + import pygame class GameView: @@ -31,29 +35,36 @@ class GameView: surface.fill("black") for cell in self.game.walls.walls(): - pygame.draw.rect(surface, "white", pygame.Rect( - cell.x*self.cellWidth, - cell.y*self.cellWidth, - self.cellWidth, - self.cellWidth - )) + self._drawBoxOfColor(surface, "white", cell.x, cell.y) + + for static in self.game.statics: + match static: + case Door(): + if static.isOpen(): + self._drawBoxOfColor(surface, "lightgray", static.pos.x, static.pos.y) + else: + self._drawBoxOfColor(surface, "gray", static.pos.x, static.pos.y) + case PressurePlate(): + self._drawBoxOfColor(surface, "yellow", static.pos.x, static.pos.y) + case Trail(): + if static.isOn(): + self._drawBoxOfColor(surface, "pink", static.pos.x, static.pos.y) + else: + self._drawBoxOfColor(surface, "purple", static.pos.x, static.pos.y) for box in self.game.boxes: - pygame.draw.rect(surface, "brown", pygame.Rect( - box.pos.x*self.cellWidth, - box.pos.y*self.cellWidth, - self.cellWidth, - self.cellWidth - )) + self._drawBoxOfColor(surface, "brown", box.pos.x, box.pos.y) for cell in self.game.snake.cells: - pygame.draw.rect(surface, "red", pygame.Rect( - cell.x*self.cellWidth, - cell.y*self.cellWidth, - self.cellWidth, - self.cellWidth - )) - + self._drawBoxOfColor(surface, "red", cell.x, cell.y) + + def _drawBoxOfColor(self, surface, color, x, y): + pygame.draw.rect(surface, color, pygame.Rect( + x*self.cellWidth, + y*self.cellWidth, + self.cellWidth, + self.cellWidth + )) def update(self, time): |
