5 hours ago, LazyDev said:
After a while, the player can only turn left for some reason ?
You shouldn't treat code as a black box that magically produces the correct answer. The computation is right there and it's not difficult, so take some time to study and understand it. Once you understand how it is intended to work, get an example where it fails, and do the computation step by step (either in a debugger or even manually with a calculator). At which point does the example deviate from the intended answer? Why?
That is the information you want to start thinking about a solution.
If you want to discuss it here, please provide a concrete example of from_angle and to_angle where the code fails, so others can verify your findings, and play with the code to find the cause. It may also clarify what you mean, eg I have no idea what "left" means, the code only has positive and negative rotations, there is no left or right in there.
As I ran an exhaustive test while writing that code, my first random guess of your problem is that you're not obeying the input conditions. Of course my tests may be flawed as well, so I am quite interested in an example where the code gives an incorrect answer.