summaryrefslogtreecommitdiff
path: root/Game.py
diff options
context:
space:
mode:
authorJoel Kronqvist <joel.kronqvist@iki.fi>2025-11-01 17:19:27 +0200
committerJoel Kronqvist <joel.kronqvist@iki.fi>2025-11-01 17:19:27 +0200
commit394959f11cdf5493673d60df4cb7a98683fc6afc (patch)
treeeca0c9cee6c95ecc299270b5de519d3c28043e06 /Game.py
parentae319acbf4c29551be07c1406c434e129a84b51e (diff)
downloadSnakePuzzle-394959f11cdf5493673d60df4cb7a98683fc6afc.tar.gz
SnakePuzzle-394959f11cdf5493673d60df4cb7a98683fc6afc.zip
fix: boxes pushable through tail
Diffstat (limited to 'Game.py')
-rw-r--r--Game.py6
1 files changed, 4 insertions, 2 deletions
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