Good coding guidelines / February 26, 2014

Boolean Function Parameters

Consider the following code, which might be part of a custom Font class to draw fancy text. Looks good, right? Parameters are clear, order makes sense, and it’s easy to understand what the code does when you find it invoked: No need to go searching for the function implementation, or hovering over using the IDE

Read More
Code / February 16, 2014

Don’t use Suspend and Resume, but don’t poll either.

So, using thread Suspend and Resume functionality is deprecated in Delphi, Freepascal, and even Windows MSDN itself warns against using it for synchronization. There are good reasons for trying to kill this paradigm: suspending and resuming other threads from the one you’re currently on is a deadlock waiting to happen, and it’s typically not supported at all

Read More
Good coding guidelines / February 12, 2014

Default Audio Device

In Windows Vista and earlier, the operating system managed a list of audio (playback) devices, and one of them was always specified as the ‘default’. This is how audio devices may have looked on such a system: Speakers (Default) USB Headset Realtek rear audio jack Applications using Windows’ built-in sound functions such as PlaySound() always

Read More
Code / February 7, 2014

Sleep vs WaitMessage vs MsgWaitForMultipleObjects

This topic seems to come up quite a lot, and yet the majority of the time, there’s no clear answer. Take the scenario: you have a game or an application, and there’s some downtime. You’ve noticed in task manager that your apps remains at a high CPU Usage% even while it’s not doing anything, and

Read More
Code / January 25, 2014

Sometimes it’s the driver

Consider this pseudocode: Is there a memory leak in the above code? This is just pseudocode, so I’m not trying to be tricky with syntax and I haven’t omitted any key steps in init or shutdown. The answer I should get is “no”. And yet, in reality, the answer is “maybe”. All the code does

Read More
Good coding guidelines / February 10, 2011

UI Testing

Sometimes, you produce a UI that makes perfect sense to you, but when you introduce it to another player, they can’t follow it. That happened to me with Icefall’s UI bar. Originally, my layout placed the player character’s health and mana bars in the bottom left corner, with the player’s current target displayed next to

Read More
Good coding guidelines / March 7, 2010

3rd Party Code

As a general rule, I like to write all of the code used by my games/programs myself. Not because I think I am the best programmer in the world, but because – for me – one of the main reasons I program is to learn more about how software functions on the very lowest levels,

Read More
Good coding guidelines / December 15, 2009

Game Golden Rule #2: Settings & Controls

This is the second entry in my set of “10 Game Development Golden Rules”. Hopefully, this one is less contentious than the first! The rule is: Provide gamma and volume controls, and separate music from sound. Pretty simple. But essential! The good news is, the AAA titles pretty much universally support this now. And it’s

Read More
Good coding guidelines / December 6, 2009

Assets as Text Files!

OK, this trick is probably universally known, but I’ve only just discovered it (by the classic programmer method of reinventing it), so on the chance there are others who are unfamiliar with this technique, it’s worth describing. Any sufficiently complex game is going to have “assets”: data external to the main program that the game

Read More