Is this a good way to find the angle of the mouse to a set position in pygame | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Is this a good way to find the angle of the mouse to a set position in pygame

I am trying to figure out trigonometry so i can use it in some projects, and this part of it in particular seems like it would help a lot in making games. Are there any other/ better methods to do this? https://sololearn.com/compiler-playground/cgR23FqZuYtF/?ref=app

5th May 2024, 12:28 PM
Christos fiotakis
Christos fiotakis - avatar
1 Resposta
+ 2
At a quick glance, that looks normal. In case itā€™s what you were asking, yes, trigonometry is what you need here. One thing I noticed he doesnā€™t deal with is that some of the trigonometry functions will trim off increments of either 90 or 180Ā° if I remember right, so you have to do some checking as to if any axes are negative to add those back in. I donā€™t remember which ones, but his program will show you the angle changing in real time, so you can figure it out from that.
5th May 2024, 2:04 PM
Wilbur Jaywright
Wilbur Jaywright - avatar