Calculating enemy sprite direction vector to face player
lol this is part 2 of my trig confusion..please feel free to engage :D
Right, to calculate the look vector I was using an original arrow sprite
that looked like this:
green arrow, get it? :D
em, anyways it was supposed to track the mouse as i moved it..
and this simple formula worked to calculate the angle of rotation:
and it worked perfectly..
rotAngle = Math.Atan2(Mouse.GetState().X - arrowPos.X, Mouse.GetState().Y-arrowPos.Y);
so I decided to use it with my ship.
Attachment 10628 (hello again)
the initial heading I used was 90 degrees (the right ship)...and when I used the above code..it wasn't working :( (oh, the horror!)
adding +90 to the rotAngle made it only slightly better..but it wasn't looking at the freaking player..
so I looked at the arrow sprite again and saw that the heading was different (hence why I was asking how to calculate the new x and y positions, thinking about it I should probably have asked this question first)
so I made the ship face 3 o'clock and re ran the code..and wow it tracked the player perfectly..oh the joy!
So my question is why did the atan2 formula not working for the 90 degree heading but it worked for the 0 degree heading?
I hope what I asked is clear..I like to tell stories a lot :(