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

Method move

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

Moves the snake forward by moving each segment to the position of the one in front.

(self)

Source from the content-addressed store, hash-verified

36 self.segments[0].color(colors.FIRST_SEGMENT_COLOR)
37
38 def move(self):
39 """ Moves the snake forward by moving each segment to the position of the one in front."""
40 for i in range(len(self.segments) - 1, 0, -1):
41 x = self.segments[i - 1].xcor()
42 y = self.segments[i - 1].ycor()
43 self.segments[i].goto(x, y)
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."""

Callers 1

game_loopFunction · 0.45

Calls 1

forwardMethod · 0.45

Tested by

no test coverage detected