Setting the angle of a turtle in Python
Asked Answered
E

2

8

I'm creating a function that will cause a giraffe to move in a certain direction and distance (don't ask).

If the user types "west" in the parameters, the turtle should move west however the direction is. But the turtle's angle changes every time, I can't fix a value for my turtle to turn to go a certain direction.

I need to set the angle to, say, 90 so that it can move East. I can't find useful functions for this purpose. I tried to use Pen().degrees(90) but that didn't work. Does anyone know how I can do this?

Ellary answered 10/12, 2013 at 18:45 Comment(2)
do you have any code? it's hard to see what you're doing and explain how to fix it without any..Haughty
Yeah, some code from whatever you are trying would help.Nocturnal
A
12

You're looking for turtle.setheading()

>>> turtle.setheading(90)
>>> turtle.heading()
90.0

You can combine this with a simple dict to get exactly the result you are after.

Apochromatic answered 10/12, 2013 at 18:58 Comment(1)
Thanks. When I tried this, it gave me an error, but I believe that I can resolve that. Thanks!Ellary
B
-3

turtle.right(90) this will turn the turtle 90

Billon answered 16/3, 2018 at 22:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.