summaryrefslogtreecommitdiff
path: root/Snake.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 /Snake.py
parentae319acbf4c29551be07c1406c434e129a84b51e (diff)
downloadSnakePuzzle-394959f11cdf5493673d60df4cb7a98683fc6afc.tar.gz
SnakePuzzle-394959f11cdf5493673d60df4cb7a98683fc6afc.zip
fix: boxes pushable through tail
Diffstat (limited to 'Snake.py')
-rw-r--r--Snake.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/Snake.py b/Snake.py
index c53af73..a1e3dc4 100644
--- a/Snake.py
+++ b/Snake.py
@@ -16,13 +16,11 @@ class Snake:
def move(self):
nextPos = self.cells[0] + self.heading
+ last = self.cells.pop()
if self.game.enter(nextPos, self.heading):
- if nextPos in self.cells[1:len(self.cells)-1]:
- self.hasCollided = True
- else:
- self.cells.pop()
- self.cells.insert(0, nextPos)
+ self.cells.insert(0, nextPos)
else:
+ self.cells.append(last)
self.hasCollided = True
def head(self):