From d820a7469b2296e4fb058fff2b00dd7848364739 Mon Sep 17 00:00:00 2001 From: Geoffrey Allott Date: Sun, 25 Dec 2022 19:42:34 +0000 Subject: [PATCH] figure out actions before moving snakes --- snake.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/snake.py b/snake.py index c4cd0aa..bdad650 100644 --- a/snake.py +++ b/snake.py @@ -337,12 +337,18 @@ class GameArea: def update(self): self.frame += 1 + actions = {} for snake in self.snakes: if not snake.alive: continue if not snake.turbo and self.frame % 2 == 0: continue snake.slither() r, c = snake.segments[-1] - action = self.tiles[r][c].action() + actions[snake] = self.tiles[r][c].action() + for snake in self.snakes: + if not snake.alive: continue + if not snake.turbo and self.frame % 2 == 0: continue + r, c = snake.segments[-1] + action = actions[snake] if action.is_teleport(): self.tiles[r][c] = EmptyTile() r, c = snake.segments[-1] = action.row, action.column -- 2.34.1