A simple demonstration of a sprite rotating to a target direction, the direction here being to the mouse-pointer. To find the signed difference in two directions, do: ((((target_direction - direction) + 180) mod 360) - 180) This works correctly for all pairs of angles and will always return the difference closest to 0 (no difference greater than 180 or smaller than -180). A small explanation for how it works: When you find the difference in direction by simply subtracting one direction from the other, some differences will be excessively large. Instead you want to wrap at -180 or 180 degrees. Modulo of 360 places the seam at 0 or 360 so by adding 180 before it and subtracting it after, the seam is offset to the correct position.