Category Archives: Uncategorized

Game Setup and Libraries

So let’s get started. Using a copy of Visual Studio 2010 (or Express) and XNA 4 for WP7 installed I set about creating a few projects. I found it’s a good way of separating the game code from reusable components.

I created the following Windows Phone Game Libraries:

Controller, Core Library, Utility and a multiplayer library.

Initially, they are empty but it’s a good starting block. Then I created the Windows Phone Game project (with the content project for assets). Making the game reference all the other libraries we’re good to go.

As you can imagine, the libraries are self-explanatary. The controller library will hold the gesture reading code (in the future it can handle controllers and keyboards). I decided that the Core Library will be reusable components for any game and potentially any platform (C# ones that is). I was thinking this library should contain the Gui library, rendering component and object management. The Utility library should contain any maths functions, file handling and especially XML handling. I note this because there is no XmlDocument like in normal WinForms. We have to use XDocument instead, so I thought this needs to be wrapped up.

On opening the game project, I stripped out all the functionality to leave one function.


/// This is the main type for your game

public class MyGame : GameCore
public override void OnPreLoad()
GameScreen s = new GameScreen(this);

As you can see I’ve created a class called GameCore and this now hosts all the functions instead. I did this as the code is similar from game to game and almost the same for each platform. The only difference between say 360 and WP7 is the screen resolution and timing line.

In┬ámy next post, I’ll talk about setting up game screens and move on to the Gui rendering.