title: Rotating an image towards the mouse's current position
body: <p>I am trying to make a simple game in XNA.</p>
  
  <p>I have a player which has spritesheet next to it.
  The spritesheet is a sort of weapon, with a tip.</p>
  
  <p>How can I get this sprite to rotate with the tip facing the mouse position?</p>
  
  <pre><code>        float y2 = m_Mouse.Y;
          float y1 = m_WeaponOrigin.Y;
          float x2 = m_Mouse.X;
          float x1 = m_WeaponOrigin.X;
  
          // Get angle from mouse position.
          m_Radians = (float) Math.Atan2((y2 - y1), (x2 - x1));
  
  Drawing with: 
  activeSpriteBatch.Draw(m_WeaponImage, m_WeaponPos, r, Color.White, m_Radians, m_WeaponOrigin, 1.0f, SpriteEffects.None, 0.100f);
  </code></pre>
  
  <p>while this makes it rotate, it does not follow the mouse correctly, and it behaves weirdly.</p>
  
  <p>Any hints on how to make this work?</p>
  
  <p>Another issue I have is to define a point and which is the muzzle, and update it based on the angle as well, so that shots will fire correctly from that point towards the mouse.</p>
  
  <p>Thanks</p>
  
  <hr>
  
  <p>Screenshots:
  <img src="https://i.stack.imgur.com/nUMe4.png" alt="early, getting the mouse and cursor in place"></p>
  
  <p><img src="https://i.stack.imgur.com/NFbsM.png" alt="playing with the super laser"></p>
  
  <p><img src="https://i.stack.imgur.com/HHUpC.jpg" alt="using the superlaser on every enemy type"></p>
  
  <p>Thanks again, turned out to be a fun game.</p>