I have a randomly placed number of points on screen and a player. What I am trying to do is move the player to the closest point depending on what key they press, so down would look for all the points closest to 90degrees then sort them by distance and then move the player to the closest point.
The problem is I dont know how to work out the distance between two angles. The problem is that 360 is also 0, so although a point at 350 degress would actually be the closest point to zero, my crappy function would return a distance of 350, instead of 10..and it would break.
Is there a function that will give you the distance between two angles?
So that the distance between a point at 1 degree and a point at 359 degress would actually be 2?
Angles confuse me, well, its the fact that 360 is also zero thats hurting ma brain!
Thanks if anyone can help!
P.S. What I am actually writing is a menu system, it can have any amount of randomly placed options that are selected by pressing up/down/left/right. I need to find the closest option based on the direction of the key press. I've got them all sorted by distance, now I need to arrange them by the angle closest to the target direction. Anyone seen any source similar to this? Ta.
The problem is I dont know how to work out the distance between two angles. The problem is that 360 is also 0, so although a point at 350 degress would actually be the closest point to zero, my crappy function would return a distance of 350, instead of 10..and it would break.
Is there a function that will give you the distance between two angles?
So that the distance between a point at 1 degree and a point at 359 degress would actually be 2?
Angles confuse me, well, its the fact that 360 is also zero thats hurting ma brain!
Thanks if anyone can help!
P.S. What I am actually writing is a menu system, it can have any amount of randomly placed options that are selected by pressing up/down/left/right. I need to find the closest option based on the direction of the key press. I've got them all sorted by distance, now I need to arrange them by the angle closest to the target direction. Anyone seen any source similar to this? Ta.