Since I’ve tackled getting up and running on the iOS platform in my previous post in this “Developing a game for the iOS and Windows Phone 7 Platforms at the same time” series, I’m now moving onto getting started with Windows Phone 7 game development. Like the previous post, the aim of this one is to have you up and running with a basic skeleton that we will build upon over the coming weeks.
Getting the tools
Unlike iOS development, the tools for WP7 are free. You still need to pay Microsoft money to have your app published on the app store, but to actually get started, you don’t need to spend anything.
- Visual Studio 2010 Express for Windows Phone – Microsoft have made a special version of their excellent Visual Studio IDE available to download for free. This version doesn’t come with all the tools and features of the commercial versions, but we don’t need anything like that. To make live a little easier, Microsoft has a full package called Windows Phone Developer Tools, which you can download. This contains almost everything you’ll need. It’s a small download that will download and installed the tools.
- Farseer Physics Engine – The Farseer physics framework will provide us with a powerful physics engine needed to drive our game. Download Farseer Physics Engine 3.3 XNA, the current stable release. Install it once you’ve installed the Windows Phone Developer Tools
I’ve got it all installed
Once you have everything installed, launch Visual Studio and start a new project (File->New->Project). In the New Project dialog, select the Windows Phone Game (4.0) project under the XNA Game Studio 4 Template group. Name the project “Windows Phone 7 Game” and change the location if you wish. I typically keep all my code under a directory called “Development”. It makes things easy to find.
You’ll end up with a new Solution and the very basic elements for a Windows Phone 7 Game.
Hit F5 to build and run the project. If you see an error dialog popping up, check that the Error List. If it says “Zune software is not launched. Retry after making sure that Zune software is launched.” then ensure that “Windows Phone 7 Emulator” is selected and not “Windows Phone 7 Device”. This setting is in one of the toolbars along the top. This setting controls how the game is executed. We’re using the Simulator tool for now. If you’ve had to change this, hit F5 again.
The WP7 simulator will launch and you’ll be presented with a blue screen. Don’t worry, this is all it is supposed to do right now.
Adding some physics
We will now include the Farseer framework into our project and stop there. Once you’ve downloaded the Farseer Physics Engine 3.3 XNA zip file, open it. It will contain a folder Farseer Physics Engine 3.3 XNA. Copy this folder from the zip file and paste it in the same location as your Visual Studio Solution file. In my case, this would be D:DevelopmentWindows Phone 7 Game. By copy the framework here, it lets us keep all our code together. Very important when we add this solution to source control.
Return to Visual Studio, which should still contain your Windows Phone 7 Game solution. If the Solution Explorer, a tree view showing all the projects and files in your solution, is not open within VS, open it using the menu View->Show Solution Explorer. Within the Solution Explorer, right click on the Solution at the very top and choose Add->Existing Project.
An Explorer windows will appear. Simple navigate to where you pasted the “Farseer Physics Engine 3.3 XNA folder”, open it and find a file called “Farseer Physics XNA WP7.csproj”. Select this file and choose Open. It should now load this project into your solution.
Visual Studio might prompt you with Security Warning. Since we trust this Project, click Okay. In future, Visual Studio might display the same prompt when you open your solution, but just click okay.
Now that the project has been added, your Solution Explorer should look like this:
Hit F6 to build the solution, or use the menu Build->Build Solution. Everything should compile successfully.
Finally, we will include a reference to Farseer Physics project in our Windows Phone 7 Game. This basically lets one project use the classes and information in another. Right click on the Windows Phone 7 Game project and click Add Reference. Use the Projects Tab in the window that appears.
Choose the Farseer Physics XNA WP7 project and hit okay.
Hit F6 to build one final time and, if you wish, you can run the project again. The Simulator should still open with the same blue background since we haven’t really changed anything. However, we have now got a skeleton Windows Phone 7 project with a physics engine that we can build upon!
The next article or two will cover the construction of a physics world within the game. Stay tuned. Same bat time, same bat channel!