Jump to content

How to Create Your First XNA Application

+ 1
  chco's Photo
Posted Jan 13 2011 12:22 AM

This excerpt from Learning XNA 4.0 gives you a good starting off point for creating your own game or application.
Once you have XNA Game Studio 4.0 installed, it’s time to create your first XNA application. In Visual Studio, select File→New→Project. Under “Installed Templates” on the left side of the window, select Visual C#→XNA Game Studio 4.0.

On the right side of the window, you’ll notice several different options. In this case, you’ll want to create a Windows Game (4.0) project. Name the project Collision, select the directory in which you want the project saved (creating the project in the default location is perfectly fine), and click OK (see the image below).

New project creation screen

Attached Image


After the project has loaded, select Debug→Start Debugging in Visual Studio. The project will compile and then run, displaying a screen similar to the one shown below.

Running your Collision project

Attached Image


Note that if you receive the error message shown below instead of the game window, you either have a graphics card that doesn’t support DirectX 10 or you need to update the drivers for your graphics card. If your graphics card supports DirectX 9 and shader model 2.0, you can adjust your XNA game profile to use a limited API set, which will allow you to develop games using your current graphics card. To adjust the game profile, right-click your Collision project in Solution Explorer and select Properties.

Figure 2-6. “No suitable graphics card found” error

Attached Image


Set the Game profile to use “Reach” rather than “HiDef”, as shown below. After setting the profile to “Reach”, run your game again, and if your graphics card meets the minimum specs, you should see the game window. Also note that when creating a project for Windows Phone 7, the game profile defaults to Reach. When creating a project for Windows or Xbox 360, it defaults to HiDef.

Figure 2-7. Reach profile

Attached Image


Congratulations! You’ve just created your first game in XNA! It may not be the most exciting game you’ve ever played, but make no mistake, this is a 100% genuine XNA 4.0 application—and there’s a lot more going on here than meets the eye. Although the project doesn’t make use of graphics, sound, or any other cool content, the application is using the XNA Framework to draw, update, and manage resources.

Cover of Learning XNA 4.0
Learn more about this topic from Learning XNA 4.0. 

Want to develop games for Xbox 360 and Windows Phone 7? This hands-on book will get you started with Microsoft's XNA 4.0 development framework right away -- even if you have no experience developing games. Although XNA includes several key concepts that can be difficult for beginning web developers to grasp, Learning XNA 4.0 shortens the learning curve by walking you through the framework in a clear and understandable step-by-step format.

Learn More Read Now on Safari


Tags:
0 Subscribe


0 Replies