The Pillars of Good Programming

"Developing a game is like cooking a small fish."
(This is a line from the Tao Teh Ching, which I have adapted for game programming)

It may not be immediately obvious what the hell it means. To me, it means that game programming is easily done poorly, just as it is easy to burn a small fish, and make it unpalatable.

The pillars of good programming (Game or Otherwise)

  • Robustness - Robustness is THE MOST important aspect of any program. It means that the program will not cause fatal run-time errors no matter what the user does. This may seem a daunting task, and impossible to do. In fact, it IS impossible to make a program that is completely bullet-proof. No matter how smart/clever you are in implementing error handling, there is always something that you missed, and some user out there is clever enough or stupid enough to do something with your program that will cause a fatal run-time error.

  • Maintainability - This is the second most important aspect. If your code is readable, then it is easy to maintain, and therefore, easy to patch when something goes wrong. If your code looks like spaghetti, then you will have a hard time fixing or expanding the program. Make your job as easy as possible, and make the most readable code that you can.

  • Functionality - The third most important aspect, functionality means just that. The program has to DO something. More to the point, it has to do what it says it is going to do.

  • Elegance - There is a fuzzy line between elegance and functionality you can almost speak of both at the same time. Elegance is the intuitiveness of the controls, and the ease of the user interface. A complicated UI will quickly frustrate a user. Luckily, a lot of standards have been developed over the years that allow you to make your game easy to use.

  • Speed - Believe it or not, speed is the LEAST of the aspects of a program. If a program doesnít work, causes errors, fails to do what it is supposed to do, cannot be patched without an act of God or Congress, or is hard to use, it doesnít matter how fast it is. If a program DOES work, a certain amount of sluggishness is forgivable. However, you CANNOT sacrifice speed if your game takes place in real-time. You can take a bit of time between levels, when you are loading something, but thatís about it.

  • Keyboarding Conventions - For moving around, I highly suggest using the arrow keys, or the key pad (if diagonal movement is possible). The "up" arrow should ALWAYS move UP the screen in most 2d games. (Iíve seen a few isometric implementations where this is not the caseÖ bad form, and hard to useÖ lacks Elegance). In 3d games or 2d space or vehicular games, the UP arrow should always move forward. If you are using the keypad, it should not matter if the num lock key light is on or not. The user wants to play, wants to play NOW, and doesnít want to remember to press Num Lock before he starts.

  • In many sorts of games, there might be a vast array of weapons that the player can switch from at a momentís notice. There should not be more than 10 weapons that can be gained (more than that is just too much) and some of them should share the same type of ammo. The keys used for switching weapons should be the numbers 1 through 0 on the top of the keyboard.

    If there are doors in the game that need to be opened, you should use the space bar.

    For shooting/attacking, you should use the control key or the space bar.

    F1 should bring up some sort of online help, usually an explanation of the controls.

    For games with an automap, the TAB key should take you to it, or toggle its display on the screen.

    Shift key is for running, Caps Lock is for moving slowly, the alt key is for strafing.

    Escape key brings up the games main menu.

    F2 through F12 can be used their functions are up to you.

    In a FPS, PageUp and PageDown should allow you to look up or down (if the game supports that kind of thing. Also, there should also be a key defined to return you to a level viewpoint). There may also be jumping (X), crouching (C), and maybe an alternate firing button (Z). Also, if you have more than 5 weapons, you might want a button that allows you to switch to the last weapon (usually backspace)

    Lastly, while you should have all of these keys as the default keys for the various actions of the game, you should make the keyboard controls user configurable, and configurations should be able to be saved, loaded, and restored to default.

Discuss this article in the forums

Date this article was posted to 11/23/1999
(Note that this date does not necessarily correspond to the date the article was written)

See Also:

© 1999-2011 All rights reserved. Terms of Use Privacy Policy
Comments? Questions? Feedback? Click here!