diff options
| author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-11-01 16:32:45 +0200 |
|---|---|---|
| committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2025-11-01 16:32:45 +0200 |
| commit | ae319acbf4c29551be07c1406c434e129a84b51e (patch) | |
| tree | 5533cf9db4c73a7619c6107dca0842c4bc8f9319 /GameView.py | |
| parent | 57f20a5ef761985b34817846d471a064b180e089 (diff) | |
| download | SnakePuzzle-ae319acbf4c29551be07c1406c434e129a84b51e.tar.gz SnakePuzzle-ae319acbf4c29551be07c1406c434e129a84b51e.zip | |
feat: boxes, pushing, failing before entering 'solid' tiles
Diffstat (limited to 'GameView.py')
| -rw-r--r-- | GameView.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/GameView.py b/GameView.py index 241914c..50785a7 100644 --- a/GameView.py +++ b/GameView.py @@ -1,5 +1,6 @@ from Game import Game +from Box import Box import pygame class GameView: @@ -29,16 +30,24 @@ class GameView: surface.fill("black") - for cell in self.game.snake.cells: - pygame.draw.rect(surface, "red", pygame.Rect( + 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 )) - for cell in self.game.walls.walls(): - pygame.draw.rect(surface, "white", pygame.Rect( + 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 + )) + + for cell in self.game.snake.cells: + pygame.draw.rect(surface, "red", pygame.Rect( cell.x*self.cellWidth, cell.y*self.cellWidth, self.cellWidth, @@ -46,6 +55,7 @@ class GameView: )) + def update(self, time): if (self._previousTick == None) or (self._previousTick + self._tickTime <= time): self._previousTick = time |
