Skip to content

Commit

Permalink
Reset the trail between games.
Browse files Browse the repository at this point in the history
  • Loading branch information
amtoine committed Jul 5, 2021
1 parent 943f10a commit 7ff4b39
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Snake.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 7ff4b39

Please sign in to comment.