Using Monkey for a XNA Xbox Project : Revisit

On the 16th of August I wrote an article describing my experience using Monkey to make an XNA project. I was quite critical (though I believe fair) about it and closed by mentioning that I was sure all of the issues I had were just because Monkey was still in development. This is pretty much the case and I will go through the areas that I previously had a problem with.

Text files unnecessarily converted to strings : Fixed

Then: Monkey converted all text files in to a function that dished out the content. This content was stored within the source of the function, this was a nightmare if you had lots of text files, which I did with 50 CSV files containing the levels. This coupled with the whole “all source in one file thing” was an absolute nightmare. As a way for guaranteeing a load file system worked universally it made sense, but really it was unnecessary because XNA is capable of reading files.

Now: Monkey now stores text files as text files within the XNA project. Sorted.

All source gets stored in one file : Not Fixed But Not A Problem?

Then: Monkey generated a single C# source file for the XNA project. With Ninjah I had around 30 source files within Monkey and they were all dumped in to a single source file in XNA. This with the level data also being stored in source was just too much for my laptop.

Now: Monkey still generates a single C# file, but because the levels (or any other external text files you might have) aren’t included it isn’t nearly as much of a problem now. In truth this was only a problem because I needed to go in and edit the generated code for simple things like changing the app name and the resolution, as well as more complex things (like adding music playback that worked!). I’m yet to see a reason why I need to edit the generated source now so this is probably a void point now.

You need to make changes to the generated code : Fixed

Then: (I know I am repeating myself a bit here but…) As mentioned, there were reasons why I needed to edit the generated source code. I needed to edit the app name and resolution details, I needed to fix the joypad code (to pass peer review), I needed to add my own music playback system (to avoid compiling music… I’ll get to that) and I needed to add the level data at source level (so I literally had to generate C# code for the levels in array format, to stop the slow loading). The biggest issue with this was the fact that once you change the C# code, you can’t rebuild the Monkey code because any changes would get overwritten. I ended up stuck in a horrible limbo.

Now: This is no longer required. The app level config settings are now stored within a separate CONFIG.TXT file which is really handy. The other mentioned issues have now been fixed as well.

The trans process repeatedly processes all media every time you build : Fixed

Then: XNA compiles media in to an XNB format, so all sound and music files (WAV/WMA/MP3) are processed when the app is compiled. For small sound effects this was never a problem. But as soon as you add a few music tracks, this impacted on the build time significantly. I am literally talking about an hour and a half each and every time I built Ninjah. I had to add my own music playback to the C# source to avoid music getting processed, but even then the sound effects were still getting rebuilt each time (so around 15-20 minutes per build).

Now: Media only get’s compiled once (unless it changes), this is perfect. Even better is, XNA now handles music differently as well…

Music tracks are converted into XNB files : Fixed

Then: Monkey was converting music files to XNB files (which I think are encrypted wav files?). First problem was the fact this converted 40mb of music in to 400mb and secondly as previously mentioned, it took an hour and a half to compile each and every time! Even having to do this once is not ideal.

Now: Monkey now has a nice little system in place where you specify what types of media are music/sound/graphic/text data and it handles it from there. This means that WMA files are now stored as WMA files without any harsh and time consuming conversions. MP3 files will still be converted to WMA files, but any XNA project would do this with or without Monkey.


I would definitely recommend using Monkey for an Xbox game now (something that I hadn’t intended on just yet, but am now doing!).