Moves the snake forward by moving each segment to the position of the one in front.
(self)
| 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.""" |