   Crosshair Follow
  Does anybody know how I would get my character to face the mouse controlled crosshair in a 2d shootemup game? I was thinking doing if-then statements for every 10 or 15 degrees (if mouse is between y and y, load this sprite so the character faces that direction). Can anyone help me out with some code?   
  Have a look at atan2 function,pseudo code:float phi = atan2(y_cur-y_plyer,x_cur-x_player);// phi is given in radiansplayer.set_rotation(phi);+y^|  cursor|   /|  /| /  |/ )phiplayer-------> +x;  http://www.csgnetwork.com/righttricalc.htmlThis will help you out. Create a right triangle by taking the result of MousePos - PlayerPos, those are your legs of the triangle. By taking the lengths you can get the wanted angle.egMousePos = 10,5PlayerPos = 4,3result = 6,2angle = 18.43°Try to google up the formulae for the calculations of angles in right triangles.   ;  Thank you both very much for your replys. The codes work great!   ;  Alternatively, you could represent the player's direction with a normalized 2D vector, and set the facing by just subtracting and normalizing.   