From ae319acbf4c29551be07c1406c434e129a84b51e Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sat, 1 Nov 2025 16:32:45 +0200 Subject: feat: boxes, pushing, failing before entering 'solid' tiles --- GameView.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'GameView.py') 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 -- cgit v1.2.3