I want to move the turtle in random directions while keeping the turtle at the center of the screen. How can I do this?
While True:
turtle.setheading(random.randint(0,360))
turtle.forward(10)
2 Answers 2
I want the camera screen to follow the turtle whereever its going.
You can do this by manipulating the scroll position using methods of the underlying tkinter window structure. Here's a turtle example that moves a ball but keeps it centered in the window.
Comments
What do you mean by "center of the screen"? Your code is turning your turtle by 0 to 360 and then move 10 forward. If you dont want to move the turtle remove the turtle.forward(10).
To move your turtle back to the start you could add turtle.home().
While True:
turtle.setheading(random.randint(0,360))
turtle.forward(10)
turtle.home()