Tuesday 9 October 2007

On a Bug Hunt

One of the most labour intensive parts of game programming (and programming in general) is bug hunting and optimisation. Even if you are a programming genius like what I is bugs can still sneak in to your code when your back is turned.

The only way to track them down is to play, play and play your game again. Be your own most dedicated play tester. One of the tests that I do is create a windowed mode for the game, and play it alongside a CPU monitor. This can give you some big clues as to where there are performance bottlenecks in your game.

For example, I found that while the game was playing, the CPU usage was only 2 - 3%, but pressing fire knocked it up to 70%. Ouch! That was fixed by merging the base drawing and player shot collision code into a single run.

Another bug was down to programmer daftness. Because I'd made the enemy shots part of the enemy structure, when an enemy was destroyed their shot vanished too. D'oh! Needless to say I've created a new structure just to hold the shots and moved the enemy shot code into its own section. This involved some major restructuring of the code but was well worth it.

I've added a simple (but effective) end sequence that fits in with the retro styling of the game.

I'll have to have a run through the code and see where else it can be cleaned up before adding in the final missing features. Dull work, but necessary.

No comments: