how to rotate turtle shape in python

12,887

Solution 1

I had the same issue with Python turtle graphics. I circumvented it by registering different images in different rotational states. Then you can use conditional statements to show a suitable image in each partcular state. Hope it helps!

Solution 2

I found that this will not be possible, according to the documentation of the register_shape() method:

Note: Image shapes do not rotate when turning the turtle, so they do not display the heading of the turtle!

Reference: http://docs.python.org/library/turtle.html#turtle.register_shape


However, it seems that there are two other ways to use register_shape() which should provide rotation, since the above disclaimer only refers to image shapes.

  1. Using coordinates to draw a polygon shape.
  2. Using a compound shape object (a compound shape consists of multiple polygons).
Share:
12,887
Greg Peckory
Author by

Greg Peckory

Updated on June 04, 2022

Comments

  • Greg Peckory
    Greg Peckory almost 2 years

    I registered the shape of my turtle in my roulette game to a roulette wheel. I want the wheel to spin 3 times. This is my program:

    register_shape("wheel.gif")
    wheel = None
    wheel = turtle.Turtle()
    wheel.ht()
    wheel.shape("wheel.gif")
    
    
    wheel.shapesize(5, 5)
    wheel.pu()
    wheel.ht()
    wheel.goto(-200,-200)
    wheel.st()
    r = 1
    for r in range(108):
        wheel.right(10)
    

    The wheel shows up properly but it doesn't seem to spin. I would assume this should work. If not is there any other way. Thank you.