How to code games for the PC and Xbox 360

Game coding
Visual C# Express is one part of the Visual Studio suite, the hub for all Microsoft platform development

Don't believe them. Games programmers, that is.

They moan about how hard it is to make games in today's world.

They spout off almost-unimaginable figures of how much games cost to make, blissfully unaware that the figures they bandy about so easily dwarf the GDP of some smaller countries.

And then of course, they complain about how high the piracy rate is, which apparently 'costs the industry more money than Microsoft makes in a year', thus somehow justifying DRM that's more invasive than being strip-searched at Heathrow.

Listen carefully, for we shall say this only once: making games is easy. Really easy. And no, we don't mean using numpty tools clicking on buttons to 'make' simple little 2D games. We mean making full-blown 3D games with physics, networking, sound effects and more. I'm talking vertex shaders, pixel shaders, particle systems, multithreading, peer-to-peer games that work on any modern Windows PC – and can even work on Xbox 360 if you're so inclined.

All these features are possible thanks to a magic piece of software called XNA, which stands – cunningly enough – for XNA's Not Acronymed. XNA is a very thin piece of programming created by Microsoft, and it sits directly on top of DirectX. If you've ever tried to program with DirectX before, you'll know that it's an absolute nightmare… But XNA is different.

If you've never programmed at all before, then XNA will save you years of hard work, because it's designed to make it easy to drop in all the features that people want in modern games.

Yes, it does mean programming things. But on the flip side, that means you have complete creative control over your game – you can make everything from Frogger to Halo 3 if you have the talent around, because everything that DirectX can do, XNA can do, too.

You'll need this

Before you unleash your brain to code the game you've been plotting for years (and don't try to deny it – every real gamer has a dream game idea they've been nursing), you need to install some software. Don't worry, it's free: Microsoft very kindly enables just about all the XNA functionality on Windows for no charge.

If you want to take your game and run it on an Xbox 360, which enables support for playing online using Xbox Live, you need to pay a small annual fee to Microsoft. However, if you pay that fee, you also gain the right to sell your game on the Xbox Live Marketplace; Microsoft acts as your publisher and gives you a 70 per cent cut of all the money your game makes.

Anyway, back to the software: you need to download and install Visual C# 2008 Express Edition then download and install XNA Game Studio 3.0.

That's all the software you need to create your games, but if you want to run them on other computers you need to have those people download and install the XNA 3.0 redistributable – that includes only the bits required to play XNA games, not to make them.

You may also need to install the .NET Framework but a lot of people already have that installed. .NET 3.5 (the latest version) comes with Visual C# 2008, so you don't need it if you've already installed Visual C#.

Hardware requirements

So, that's the software sorted out. In terms of hardware, remember that XNA is built on top of DirectX 9.0c – in order for a PC to play games you make (even simple ones), it must fully support DX9.

It should also support – at the absolute minimum – shader model 2.0, which is any card marketed as supporting DX9. You can get away with cards that support only shader model 1.1, but it will limit you if you want to do more advanced effects.