Export (0) Print
Expand All
3 out of 4 rated this helpful - Rate this topic

Beginning 2D Game Development

In this article, you learn how to write a 2D game for the Windows Phone 7 platform. You will see how to leverage the XNA Game Studio 4.0 gaming libraries typically used to write games for the PC and Xbox 360 platforms. This article introduces the main game loop, state machines, and collision detection. When you have completed the article, you will have developed a complete functioning space-shooting game called Mars Invasion that can be run on Windows Phone 7 hardware or the built-in emulator software that is included with the Windows Phone developer tools.

In addition to providing the capability to write powerful and rich Silverlight-based applications, the Windows Phone 7 platform also fully integrates support for the XNA gaming platform. The XNA gaming platform provides an easy way for independent developers to create games for the Windows PC platform, the Xbox 360 console, and Windows Phone 7 devices.

This article takes you step by step through the development of a simple 2-D game using XNA Game Studio 4.0. After you have completed this article, you should have a solid understanding of the basic techniques required for developing Windows Phone 7 games.

This article is intended for .NET developers who are familiar with the C# programming language and the basics of Windows Phone 7 application development. You do not need previous knowledge of the XNA platform or of how to write games on the phone.

Before getting started, you need to make sure you have the required software installed. If you already have Visual Studio 2010 Professional or Ultimate, the only requirement is to download the Windows Phone Developer Tools, which include the free XNA Game Studio 4.0 software. If you do not currently have a copy of Visual Studio 2010, the Windows Phone Developer Tools installation automatically installs a copy of Visual Studio 2010 Express Edition. This is a free, fully functioning version of Visual Studio 2010 that does not have source control integration, testing tools, and some other Visual Studio features that you won’t need for this article.

A Windows Phone 7 device is also useful, as you can see the game in action on real hardware as you are developing it. The Windows Phone Developer Tools include a great Windows Phone Emulator that runs your game, but nothing replaces the actual device. The only way to test is to deploy the game on real hardware. If you do not have a Windows Phone 7 device, this article provides code that enables you to substitute the accelerometer for the keyboard, ensuring that you can still see and play your game in the emulator.

After the installation of the Windows Phone Developer Tools has completed, you will have everything you need to start writing games.

You might expect XNA Game Studio to be a completely separate program from Visual Studio. This isn’t the case. Instead, XNA Game Studio is integrated fully into whatever edition of Visual Studio 2010 you have installed, so all you need to worry about is running a single program to build both Silverlight applications and XNA games for the phone.

To get started, start Visual Studio and select New Project.

From the various projects available, select your choice from the XNA Game Studio 4.0 menu. In that menu, you should see an option for creating a new Windows Phone Game, as shown in Figure 1.

Figure 1. XNA Game Studio 4.0 Project Templates

Referenced Image

Select that template choice, and call the project MarsInvasion. After selecting a directory path for your new game project, click OK and wait for Visual Studio to finish creating the project structure.

Show:
© 2014 Microsoft. All rights reserved.