I am trying use tiltangle, hovewer I cannot understand how it works exactly. Everytime I run following code, it gives 122.0, I do not know how can I deal with it:
def collide(self):
initial_angle = self.tiltangle()
self.right(initial_angle + 90)
How can I get angle of an object in turtle library of Python?
You can refer to this docs.
Let's take the following description.
Imagine a robotic turtle starting at (0, 0) in the x-y plane. After an import turtle, give it the command turtle.forward(15), and it moves (on-screen!) 15 pixels in the direction it is facing, drawing a line as it moves. Give it the command turtle.right(25), and it rotates in-place 25 degrees clockwise.
That means, if you get the value of 122.0 every single time, it is because your initial_angle
value is 32.0.
So, the value changes depending on the side of an angle. If you change the script like:
self.left(initial_angle + 90)
Then, you would get the value of 58.0.