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

Method add_segment

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

Adds a new segment to the snake.

(self, position)

Source from the content-addressed store, hash-verified

23 self.segments[0].color(colors.FIRST_SEGMENT_COLOR)
24
25 def add_segment(self, position):
26 """ Adds a new segment to the snake. """
27 new_segment = Turtle(shape="square")
28 new_segment.penup()
29 new_segment.goto(position)
30 new_segment.color(colors.BODY_COLOR)
31 self.segments.append(new_segment)
32
33 def extend(self):
34 """ Adds a new segment to the snake's tail. """

Callers 2

create_snakeMethod · 0.95
extendMethod · 0.95

Calls 2

colorMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected