motorollin said:
That works! Thanks
Now, to work out *why* it works, so I understand for next time...
Thanks again!
squidge posted this link:
http://en.wikipedia.org/wiki/Trigonometry
it wasn't a joke. everything you need to know is in there.
picture a triangle with one leg going in the +x direction, and one leg going in the +y direction, from the origin. the third leg will connect the endpoints of the other two. let's say from (0,4) to (5,0).
so our triangle has points A(0,0), B(0,4), and C(5,0). our sprite is at point B. we need it at C. so we either do x-4 and y+5, or we move along diagonal line BC. but what is the angle of BC?
sine, cosine and tan are the functions will tell us this angle if we know the ratio of the lengths of the sides. since our "sides" are -4 and +5, we can easily get the angle of a line that will get us to the same place.
only problem is, arm cpu is not designed for trig and floating point, it is designed to do simpler math very efficiently at the cost of more complex stuff being slower. so it's best to make a table of the sin & cos functions rather than computing them at runtime.
well, you do compute them at runtime but you do it during loading, like the good example charlieb made.