How do you make two turtles draw at once in Python?
Question:
How do you make two turtles draw at once? I know how to make turtles draw and how to make two or more but I don’t know how you can make them draw at the same time.
Please help!
Answers:
Here’s a minimalist example using timer events:
import turtle
t1 = turtle.Turtle(shape="turtle")
t2 = turtle.Turtle(shape="turtle")
t1.setheading(45)
t2.setheading(-135)
def move_t1():
t1.forward(1)
turtle.ontimer(move_t1, 10)
def move_t2():
t2.forward(1)
turtle.ontimer(move_t2, 10)
turtle.ontimer(move_t1, 10)
turtle.ontimer(move_t2, 10)
turtle.exitonclick()
How do you make two turtles draw at once? I know how to make turtles draw and how to make two or more but I don’t know how you can make them draw at the same time.
Please help!
Here’s a minimalist example using timer events:
import turtle
t1 = turtle.Turtle(shape="turtle")
t2 = turtle.Turtle(shape="turtle")
t1.setheading(45)
t2.setheading(-135)
def move_t1():
t1.forward(1)
turtle.ontimer(move_t1, 10)
def move_t2():
t2.forward(1)
turtle.ontimer(move_t2, 10)
turtle.ontimer(move_t1, 10)
turtle.ontimer(move_t2, 10)
turtle.exitonclick()