title: Projectile fires from the wrong location
body: <p>I create the projectile when I press the space bar like this</p>
  
  <pre><code>if (keyboard.IsKeyDown(Keys.Space) &amp;&amp; shoot)
  {
      shoot = false;
      this.fire.Play(.2f, .9f, 0);
      lazerX = (float)(spritePosX);
      lazerY = (float)(spritePosY);
  
      Projectile projectile = new Projectile(heroLazer, "heroLazer",
          lazerX, lazerY, rotationAngle);
  
      Game1.AddProjectile(projectile);
  }
  </code></pre>
  
  <p>then in the Projectiles class the new instance is created like this.</p>
  
  <pre><code>public Projectile(Texture2D lazerSprite, string spriteName,
      float posx, float posy, float heading)
  {
      projectileSprite = lazerSprite;
      type = spriteName;
      spriteRotOrigin = new Vector2(projectileSprite.Width / 2, projectileSprite.Height / 2);
      spriteHeading = heading;
      spritePosX = posx; // the x position of the lazer
      spritePosY = posy; // the y position of the lazer
  
      spritePos = new Vector2(spritePosX, spritePosY);
      drawRectangle = new Rectangle((int)spritePosX, (int)spritePosY,
          projectileSprite.Width / 2, projectileSprite.Height / 2);
  
  }
  </code></pre>
  
  <p>updated like this</p>
  
  <pre><code>public void update(GameTime gameTime, KeyboardState keyboard)
  {
      //projectile active or not?
      if (active == true)
      {
          projectileAge += gameTime.ElapsedGameTime.Milliseconds;
  
          spritePosX += (float)(Math.Sin(spriteHeading) *
              gameTime.ElapsedGameTime.TotalMilliseconds) * ProjectileMoveAmount;
          spritePosY -= (float)(Math.Cos(spriteHeading) *
              gameTime.ElapsedGameTime.TotalMilliseconds) * ProjectileMoveAmount;
  
          spritePos = new Vector2(spritePosX, spritePosY);
      }
      if (projectileAge &gt; projectileLife)
      {
          active = false;
      }
  }
  </code></pre>
  
  <p>and drawn on screen like this</p>
  
  <pre><code>public void Draw(SpriteBatch spriteBatch)
  {
      spriteBatch.Draw(projectileSprite, spritePos, null,
          Color.FromNonPremultiplied(255, 255, 255, 255), spriteHeading,
          spriteRotOrigin, 1.0f, SpriteEffects.None, 0f);
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/oZrCm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oZrCm.png" alt="enter image description here"></a></p>
  
  <p>The above code works well EXCEPT that the projectile fires from the CENTER OF THE SPACESHIP. </p>
  
  <p>I can't capture an image which shows the projectile shooting from the center of the spaceship, but it does. What is wrong with my code? My trigonometry is rather weak so please be gentle and give some details.</p>
  
  <p><a href="https://i.stack.imgur.com/2SYQs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2SYQs.png" alt="spaceship facing up and then rotated right 90deg."></a></p>