Wednesday, January 09, 2008

Creating a New Project

Welcome to the first tutorial in the 2D Tutorial Series. In this tutorial series, I hope to introduce anyone who is new to C# and XNA game programming, to the programming world.

In this first tutorial, we will create a new project, in which we will work in and create our small XNA applications in. It is assumed that you have already downloaded and installed both the C# Express Edition and XNA Game Studio Express 2.0. If you haven’t, then go to the Getting Started tab on the right side of the page.

Now, since everything is downloaded, we can begin. Open up the C# Express Edition which should be accessible from the Start menu. When you open up your project you should be greeted with the Start Page.

Figure 1.1: When you open the C# Express Edition, you will be greeted with the Start Page.

Now, we want to create a new project. This project is where we will create our applications in. When you create a new project, you can choose to either create a new, empty, blank project, or you can choose from a group of project templates. These templates do nothing special. All they do is start you out with the needed code and references for you to easily start creating your application. For us, we want to select a project template called the Windows Game.

From the File tab, select New Project. After this, a New Project dialog will show up. From this dialog, you can choose what type of project you would like to create. As said previously, we want to select the Windows Game project template. This should be the first template in the list. If you don’t see this option, make sure that on the left side of the dialog, you have XNA Game Studio 2.0 selected.


Figure 1.2: Create a new project by clicking File / New Project.

Click on the Windows Game template. At the bottom of the page, you will see a few options for naming your project. I named it, TutorialProject. However, if you dislike this name, feel free to choose something different. The save location is made by default, and is probably where you want to save it. This path saves the project into the Projects directory, where you can easily access it when you open a file in XNA GSE (Game Studio Express). The final textbox is where you can specify the solution name. It is possible to have multiple projects in a single solution, so you may want to name the solution different from an individual project. For our purposes, leave the name as it is. Also, make sure that the Create directory for solution checkbox is checked because we are creating a new solution and not adding a project to an existing solution. Finally, press OK, to create the project.


Figure 1.3: When you have completed the steps above, your project profile should look similar to this.

After a few moments, you will be greeted with the Game1.cs class file, which has been created for you by default. The default code may look confusing, but after a while you will get the hang of what happens. For now though, let’s see what the default code does. Build the project by clicking the green Start Debugging arrow at the top, middle of the screen (or by pressing F5). Your project will build and you will see an already created window for you, with a nice cornflower blue color as the background.

Figure 1.4: When you build the project by clicking the green arrow or pressing F5, you will see this screen created for you by default.

It’s nice to know that you don’t have to go through all the work of creating a window by hand and that you can start seeing results very quickly. In this tutorial, you learned how to create a new project. You didn’t code anything, but that is coming in the next tutorial.

Be a hero: don’t conform; be selfless; make a difference.