From 394959f11cdf5493673d60df4cb7a98683fc6afc Mon Sep 17 00:00:00 2001 From: Joel Kronqvist Date: Sat, 1 Nov 2025 17:19:27 +0200 Subject: fix: boxes pushable through tail --- Game.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Game.py') diff --git a/Game.py b/Game.py index 6f6a063..662ce8b 100644 --- a/Game.py +++ b/Game.py @@ -47,7 +47,7 @@ class Game: walls = None def __init__(self): - self.snake = Snake([Vec2(6, 6), Vec2(6, 7), Vec2(6,8), Vec2(7,8)], self) + self.snake = Snake([Vec2(6, 6), Vec2(6, 7), Vec2(6,8), Vec2(7,8), Vec2(8, 8), Vec2(9, 8)], self) _box1 = Box(Vec2(11, 4)) _box2 = Box(Vec2(3, 10)) self.boxes = [_box1, _box2] @@ -59,7 +59,7 @@ class Game: # # # h # # t # -# tt # +# tttt # # # # b # # ### # @@ -79,6 +79,8 @@ class Game: boxAt = next(filter(lambda box: box.pos == pos, self.boxes), None) if self.walls.wallAt(pos): return False + elif pos in self.snake.cells: + return False elif boxAt != None: if self.enter(pos + inDir, inDir): boxAt.pos = pos + inDir -- cgit v1.2.3