I've finally had the time to sit down and create a simple game for my Zune. Rather than running off and creating a complex game requiring a lot of AI, etc I wanted to create a simple application so that I could focus on the XNA-specifics. I decided to make a Code Breaker game, also known as Master Mind. It's a pretty straight-forward game. There is no increasing difficulty curve and no fancy AI to be written, so it seemed like an excellent first attempt.
Before I could start I needed to install the necessary software. I already had Visual Studio 2008 and the Zune Software. Actually you don't need the full Visual Studio 2008. You can use the completely free Visual C# 2008 Express Edition instead.
You do need to sign up as a creator in the XNA Creators Club. Having done that, download the XNA Game Studio and install it. Now you're set to go.
I gathered a few sound effects and whipped up some graphics for my project. I decided that this is what I wanted the game to look like:
The background would be customizable. I wanted to be able to cycle through the available pictures on your device.
I decided on a fairly simple architecture for my game. In my main class (Game1.cs) I deal with the necessities. E.g. I load the sound effects that will be used throughout the application, and I create the GraphicsDeviceManager that will be used to draw to the screen. Apart from that I have two classes that I use. MainGame and MainMenu. As their names imply they either show a menu or the game screen. User input is handled in the main class and it then calls methods in the relevant classes. E.g. if the menu is shown and the user clicks on the Zune "squircle" then a menu item has been selected and the event should bubble to the MainMenu class and not to the MainGame class.
I do more or less the same thing in the Draw-method of the main class. Depending on what is shown on screen individual methods of the two classes are called. And the screen is updated accordingly.
I made sure to add at least some of the Zune-specific features.
Like I've already mentioned I added support for getting backgrounds from the pictures on the device.
I also let the player choose a playlist to be running in the background. (Anything already playing when the game is started will continue to play until the player actually changes this setting) I could have given full access to each individual song, but building an interface for that would have been quite ridiculous. Playlists only seemed like a good idea.
After some usability testing I found that in order to get this game working properly I needed to decide if I should incorporate the touch/sweep interface of the Zune 2.0 devices, or if I should settle for "proper" clicks only. I decided on the latter. Mainly because I still needed to rely on the center click, and it was easy to accidentally brush away to the side when trying to click. It also ment that this application would work with all Zunes.
Other design choices
In the beginning I let the player change colors by clicking up/down and going to the next "peg" by clicking right/left.
This turned out to be a bit complicated. It was quite easy to accidentally click up or down as well which would mean that you not only moved to the next peg, but also changed the previous pegs color. I ended up using the following key settings.
- Click Right - Move Right
- Click Left - Move Left
- Center Click - Change color / Click button
- Play / Pause - Change color "back"
- Back - Menu
If you want to install and run this little game you need to go through the motions filed under Prerequisites above. Open the project in Visual Studio 2008 and dock your Zune. You should then be able to deploy the release version or debug the application directly on the device.
You can download the project here
Here are some additional screenshots of the game:
I hope you enjoy it!