Movement#

superturtle.movement.fly(x, y)[source]#

Moves the turtle to (x,y) without drawing.

This is really just a simple shortcut for lifting the pen, going to a position, and putting the pen down again. But it’s such a commonly-used pattern that it makes sense to put it into a function. Here’s an example:

from turtle import forward, right
from superturtle.movement import fly

def square(size):
    for side in range(4):
        forward(size)
        right(90)

for col in range(10):
    for row in range(10):
        fly(40 * col, 40 * row)
        square(20)
superturtle.movement.update_position(x, y=None)[source]#

Updates the turtle’s position, adding x to the turtle’s current x and y to the turtle’s current y. Generally, this function should be called with two arguments, but it may also be called with a list containing x and y values:

from superturtle.movement import update_position
update_position(10, 20)
update_position([10, 20])
class superturtle.movement.restore_state_when_finished[source]#

A context manager which records the turtle’s position and heading at the beginning and restores them at the end of the code block. For example:

from turtle import forward, right
from superturtle.movement import restore_state_when_finished
for angle in range(0, 360, 15):
    with restore_state_when_finished():
        right(angle)
        forward(100)
class superturtle.movement.no_delay[source]#

A context manager which causes drawing code to run instantly.

For example:

from turtle import forward, right
from superturtle.movement import fly, no_delay
fly(-150, 150)
with no_delay():
    for i in range(720):
        forward(300)
        right(71)
input()