I am trying to rotate/pivot an image so that it points towards the center of a circle.
However, the math is resulting to be too complicated.
For example, I have tried doing things like theta = math.degrees(math.atan((target.x-self.x)/(target.y-self.y)))
, but this does not take into account the current rotation of my image.
As I am using pyglet, there is a built in variable for the sprite called rotation
, which is used to pivot the image anticlockwise.
I have had some ideas like storing the past rotation of the image and doing things like self.rotation = theta + self.past_rotation
, but this doesn't take into account things like the fact that the theta = math.degrees(math.atan((target.x-self.x)/(target.y-self.y)))
may return negative.
Please I would love help.