Xna Intro

XNA Introduction Lesson
Now we know enough C# to get by using XNA, we will start a project.
This project will only take us as far as putting some background images in our project.
Requirements
You will need:
• Visual Studio 2010 (not 2012), or Visual C# Express 2010
• XNA Game Studio 4.0
Creating a New Project
To create our XNA project, we will go to File > New > Project.
Ensure that Visual C# is selected, then go to XNA Game Studio 4.0 and make a Windows Game.


Give your game a name.

Making the Project Run
Right now, the project will not run because it uses the ‘HiDef’ API, which is not supported by the graphics card in the computers.
Double-click on the Properties entry in the Solution Explorer.

On the XNA Game Studio tab, choose Use Reach… as the ‘Game profile’. Save the project.
It will now run and display a blue screen.
Setting the Game’s Physical Size
We need to use the GraphicsDevice object that is available to us in XNA to set the size of the window in which the game will be played.
Above Game1(), set up a new GraphicsDevice variable to get access to this:
GraphicsDevice device;

Now, we will set the size to 500 x 500 pixels, in our Initialize() method.
device = graphics.GraphicsDevice;

graphics.PreferredBackBufferWidth = 500;
graphics.PreferredBackBufferHeight = 500;
graphics.IsFullScreen = false;
graphics.ApplyChanges();

Adding Background Resources
The game you will create is the new solution is open in your Visual Studio application. A solution can have multiple projects in it. One of these projects contains your code, and the other one contains the content – sprites, fonts, maps and other resources the game might need to run.
Adding our Background Sprites
There are some background sprites for this project that we will load in, so our application can display a background image, and not just the solid blue background.
On the Content project, right-click and click Add > Existing Item.
Find the...