title: Placing a rectangle in the middle of the screen (XNA sprite)
body: <p>So I'm trying to make a little game just for fun, but I went into a wall pretty quickly. I want the "player"(Gray box), to start in the very center of the screen. However, with my current code, it centers from the box cornor instead of its center. What would I have to change, before it will center from the boxes center? </p>
  
  <pre><code>        /// &lt;summary&gt;
          /// This is called when the game should draw itself.
          /// &lt;/summary&gt;
          /// &lt;param name="gameTime"&gt;Provides a snapshot of timing values.&lt;/param&gt;
          protected override void Draw(GameTime gameTime)
          {
              GraphicsDevice.Clear(Color.CornflowerBlue);
  
              Viewport viewport = GraphicsDevice.Viewport;
              Vector2 viewportmid = new Vector2(viewport.Width / 2, viewport.Height / 2);
              Vector2     origin = new Vector2(Player.Width / 2, Player.Height / 2);
              spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);
              spriteBatch.Draw(Player, viewportmid, Color.White, origin);
              spriteBatch.End();
  
              // TODO: Add your drawing code here
  
              base.Draw(gameTime);
          }
      }
  }
  </code></pre>
  
  <p>Thanks in advance! =) New to the website, so not able to post images directly. Heres a link: <a href="http://imgur.com/43NiWNY" rel="nofollow">http://imgur.com/43NiWNY</a></p>