Avatar Kart work in progress

During my down time I’ve been cracking on with XNA and am developing “Avatar Kart” – essentially Super Mario Kart on the SNES with Xbox avatars (we have to wait until XNA Game Studio 3.1 this summer for avatar support). In a couple of days I’ve managed to finish:

  • CPU Car AI
  • Physics and wall collisions
  • Terrain effects
  • Lap counts and car rankings
  • Split screen

The track is still from SMK and the cars are empty but it does the job. Although its in 3D, I’m trying to get a 2D mode7 type handling feeling, really tight controls and simple graphics. I’ve already hit the performance wall of floating point operations in the compact framework on the Xbox so will need to spend some time optimising later. I will be replacing the Mario Kart track with my own design soon.

Below is a video of how its looking so far:

Lines EX – rebuilding with XNA 3

My dissertation project saw me making an XNA game (Lines) and website to go with it (edngames.com) which used web services to make essentially a cut down Xbox Live on the PC with rich presence support, automatic high score uploading etc. I feel it was very successful (and the markers agreed) but I didn’t get the time to spend on the game portion that I wanted to, instead concentrating mainly on the distribution scenarios and the user experience. With the Xbox Live Community Arcade coming up and the new CTP of XNA 3 released, I thought it would be the right time to rewrite the game using everything I’ve learnt over the last year since I began the project ready for the Community Arcade launch “this fall”.


Instead of using SpriteBatch, I’ve decided to place 2D flat quads in 3D space. While still getting free rotation, transparency etc, I now get resolution independence and extra effects such as being able to skew sprites.

I already have the main game code so am working on the menu system. By having sprites in a 3D space, changing the camera location means aspect ratio independence too by zooming out or changing the field of view – below shows the main menu in 16:9 and 4:3 (the zooming will work with all aspect ratios meaning no stretching).

image image

My favourite benefit however is the Smash Bros. style 3D effect you can achieve by moving the camera with the right stick. Completely pointless but very cool and can help you debug the locations of your sprites in the game world.


And yes, I am aware of the hidden word in the title and it is purely accidental 🙂

XNA2.0 Dependency checking

After a lot of trial and error using Process Monitor and Virtual PC, I have finally sussed out exactly what XNA2.0 games on Windows need to run. The requirements are slightly different to XNA 1 games.

Direct X runtimes

There are four files that need to be installed in the system32 folder for XNA to initialise properly. They are:

  • xinput1_3.dll
  • x3daudio1_3.dll
  • d3dx9_31.dll, and
  • xactengine2_9.dll

The first three can be placed alongside the application exe and then load fine, but xactengine2_9.dll does not load this way for some reason, and has to be present in the system directory. Distributing these files alongside the application breaks the DirectX EULA, so they have to be installed using dxsetup.exe.

To check the presence in your XNA game, just put this code in Program.cs before game.Run() is called:

bool HasAllPrereqs = true;
// check all the required files, if any missing, return false
if (!System.IO.File.Exists(System.Environment.SystemDirectory 
    + "\\xactengine2_9.dll")) HasAllPrereqs = false;
if (!System.IO.File.Exists(System.Environment.SystemDirectory 
    + "\\d3dx9_31.dll")) HasAllPrereqs = false;
if (!System.IO.File.Exists(System.Environment.SystemDirectory 
    + "\\x3daudio1_2.dll")) HasAllPrereqs = false;
if (!System.IO.File.Exists(System.Environment.SystemDirectory 
    + "\\xinput1_3.dll")) HasAllPrereqs = false;

If HasAllPrereqs is false after those lines, exit the application before it crashes horribly when XNA tries to initialise.

Visual C++ 2005 SP1 runtimes

Even a fresh Vista install doesn’t have these. They are provided when updating Visual Studio 2005 to SP1, or installing SP1 of the .Net Framework 2.0. However, Vista comes with SP0 of .Net 2.0, meaning 99% of machines you come across will be lacking what XNA 2.0 needs. There is a 2.5MB standalone installer on the MS download site here which installs what you need even on .Net 2.0 SP0 machines. .Net 3.5 installs Net 2.0 SP1.

So if any of the following are installed, we safely have the right Visual C++ 2005 runtimes:

  • .NET Framework 2.0 SP1
  • .NET Framework 3.5
  • Visual C++ 2005 SP1 Redistributable

By looking up the product codes in the registry, we can also check at runtime if we have the runtimes (again, before game.Run()):

public static extern Int32 MsiQueryProductState(string szProduct);

…goes before the main application entry point, and

bool vccOK = false;
// check for VC++ 2005 SP1 redist (very rare in the wild)
if (MsiQueryProductState(
"{7299052b-02a4-4627-81f2-1818da5d550d}") == 5) vccOK = true;
// check for .NET Framework 2.0 SP1
if (MsiQueryProductState(
"{2FC099BD-AC9B-33EB-809C-D332E1B27C40}") == 5) vccOK = true;
// check for .NET Framework 3.5 (includes 2.0 SP1)
if (MsiQueryProductState(
"{B508B3F1-A24A-32C0-B310-85786919EF28}") == 5) vccOK = true;

If vccOK is still false, exit the application before you call game.Run().