Pointing one sprite in the direction of another

BlitzMax Forums/BlitzMax Programming/Pointing one sprite in the direction of another

Pineapple(Posted 2007) [#1]
I wrote this function (as show below) to use in pointing the enemies in my Geometry Wars-like game toward the player. Unfortunately, I can find no errors in the code that would cause it to return -1.#IND0000 no matter what the points entered.




Can anyone spot my error?


Gabriel(Posted 2007) [#2]
If the y coordinates are ever the same, you're going to run into a divide by zero operation. Not sure if that's your problem or not though.


Pineapple(Posted 2007) [#3]
Yea, good point. I'd probably get a nasty headache later on if I hadn't figured that out now. Thanks for that.


[edit] just realized that I had ASin where I should have had ACos, but changing this had no affect on the returned value.


[edit 2] I found the problem. Dummie me put leg/hypotenuse rather than hypotenuse/leg -.-