From 7ff4b39816ce46f9a11bcc6eb477c79007cf0190 Mon Sep 17 00:00:00 2001 From: Antoine Stevan Date: Mon, 5 Jul 2021 11:58:15 +0200 Subject: [PATCH] Reset the trail between games. --- src/Snake.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Snake.py b/src/Snake.py index ef0850a..ce58baf 100644 --- a/src/Snake.py +++ b/src/Snake.py @@ -32,7 +32,7 @@ def __init__(self, swiftness): self.dir, self.neck_asset = None, None # a list containing parts to add to the snake, allows better animation. - self.trail = [] + self.trail = None # the swiftness of the snake, inversely proportional to the rate at which the snake moves. # the number of life steps that the snake experienced. @@ -79,6 +79,9 @@ def spawn(self, y, x, h, w, init_length=3): # the assets are simply the head plus the right amount of body parts. self.assets = ['@'] + ['|' if self.dir in [curses.KEY_UP, curses.KEY_DOWN] else '-'] * len(tmp) + # reset the trail of the snake. + self.trail = [] + # reset the number of life steps. self.life_step = 0