MCPcopy Index your code
hub / github.com/geekcomputers/Python / reset

Method reset

Snake Game Using Turtle/snake.py:46–52  ·  view source on GitHub ↗

Hides the old snake and creates a new one for restarting the game.

(self)

Source from the content-addressed store, hash-verified

44 self.head.forward(MOVE_DISTANCE)
45
46 def reset(self):
47 """Hides the old snake and creates a new one for restarting the game."""
48 for segment in self.segments:
49 segment.hideturtle()
50 self.segments.clear()
51 self.create_snake()
52 self.head = self.segments[0]
53
54 def up(self):
55 """Turns the snake's head upwards, preventing it from reversing."""

Callers 1

restart_gameFunction · 0.45

Calls 2

create_snakeMethod · 0.95
clearMethod · 0.80

Tested by

no test coverage detected