public void pointAtLocation(Vector2 location)
{
double ydif = location.Y - this.y;
double xdif = location.X - this.x;
float atan = (float)Math.Atan(ydif/xdif);
this.angle = atan * (180f / 3.140f);
}
What I'm trying to do here is first get the angle in radians using the formula angle = atan(opp/adj), then convert that to degrees (spriteBatch.draw takes degrees, right?)
I'm testing it by pointing to the mouse position, and I'm getting erratic results. I expected to have it work in quadrant 1 and have to do some tweaking to get the other three to work, but it doesn't seem to be working anywhere. Can someone show me the mistake I'm making?