Simple Debugger

version 1/080105 by Michael Hilborn

  • Home page
  • Beginning
  • Previous
  • Next

  • Chapter: Adding debugging information to your game

    Suppose your game has a timer that quietly counts down in the background while the player goes about his business. When debugging the game, it's often handy to display this counter to (a) make certain it is actually counting down, and (b) ensure that the proper event fires off when the counter ends.

    Here's an example of how you might handle the first part with Simple Debugger, assuming that the timer is stored in a numerical value called "counter":

        Every turn:
            change counter to counter - 1;
            if we're debugging, say "// The countdown is now [counter]."

    The phrase "we're debugging" is true when the debugger has been activated by the player (in a moment, we'll demonstrate how a player can do this), and false when the debugger has been turned off. In essence, any code following an "if we're debugging" condition only gets executed if the debugger has been activated.

    This leads to the question about how a player can activate the debugger. It's easy enough. As long as the extension is installed and as long as a player is using a *debug build* of the game, a player simply types "debug" or "debug on" at the game's command line. Once the debugger has been activated, the player can turn it off with "debug off". If a player does not have access to the debug build (that is, the player is using the final release of the game), the debug commands are no longer available.