3

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)
asked Jul 11, 2021 at 15:47

2 Answers 2

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.

answered Jul 12, 2021 at 17:33
Sign up to request clarification or add additional context in comments.

Comments

1

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()
answered Jul 11, 2021 at 15:57

1 Comment

I want the camera screen to follow the turtle whereever its going.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.