Open main menu

AGIWiki/AGI Studio Template Game

< AGIWiki
Revision as of 12:48, 26 January 2015 by Sact (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
AGIWiki


The AGI Studio Template Game is a one-room game that serves as a starting point for game authors to build their own games. It features a default view for ego, a blank picture resource that is used by the first room in the game, and a default inventory object.

Perhaps most importantly, the template game provides a significant amount of code that implements basic functionality such as setting up the game's menus, saving and restoring, and a set of debugging commands. Without the template game, game programmers would have to implement these features themselves.

The template game also provides a file called defines.txt that sets up defines for the special variables, special flags, and other data that are of special meaning to the interpreter or that are used by the template game itself. The game's author should use this file to avoid the need to redefine all those items.

AGIWiki AGI Studio Template Game.png

Updates to the template game

Since the original version of the template game, there have been a few updates to make it even more convenient to use. Chris Cromer updated the template game to add a convenient debug menu, among other things.

Errors in the template game

Although the template game has been generally bug-free for a long time, from time to time, errors have slipped in. Some of these are not proper "bugs" but they nevertheless are worth mentioning.

input_recieved

The original template game misspelled the define name input_received as input_recieved. This is why programs such as the Base Logic Generator misspell the define name by default.

The spelling error was corrected in updates to the template game.

Memory leak on teleport (general)

During the attempts to update the template game with useful features such as a new debugging menu, a bug was inadvertently introduced that caused the debugging command "tp" to leak memory, eventually leading to an out of memory error.

You know if your version of the template game contains the bug if the following code appears in LOGIC.000: <syntax type="C++">

if (new_room) {          // First interpreter cycle in a new room
                        // Note: Everything other than logic 0 is discarded
                        // from memory when new.room is executed
  load.logics(90);      // Load game specific functions logic into memory
  clear.lines(24,24,0);  // clear bottom line of screen (remove ego's coords if shown)
  animate.obj(ego);
  load.view.v(ego_view_no);
  set.view.v(ego, ego_view_no);
  observe.objs(ego);
  old_clock_seconds = 255;  // make sure clock gets updated this cycle
                            // on this cycle (if turned on)
}

</syntax> If this code does appear in your version of the template game, then you should change it to: <syntax type="C++">

if (new_room) {          // First interpreter cycle in a new room
                        // Note: Everything other than logic 0 is discarded
                        // from memory when new.room is executed
  load.logics(90);      // Load game specific functions logic into memory

  if (debug_active) {
    load.logics(99); // load debug logic into memory
  }

  clear.lines(24,24,0);  // clear bottom line of screen (remove ego's coords if shown)
  animate.obj(ego);
  load.view.v(ego_view_no);
  set.view.v(ego, ego_view_no);
  observe.objs(ego);
  old_clock_seconds = 255;  // make sure clock gets updated this cycle
                            // on this cycle (if turned on)
}

</syntax> This bug has since been corrected in the template game that is available from http://www.agigames.com; however, AGI Studio may still be packaged with the version containing the bug.

Memory leak on teleport to room 0

While not properly a "bug," it is true that both the original and updated template games used to allow you to use a "tp" debugging command to teleport to room 0, which attempts to use logic 0 as a room. This causes memory leaks and can eventually lead to an out of memory error.

The biggest trouble with this bug is that once you type "tp" and press Enter there is no way to cancel the teleport. Pressing Enter with a blank entry is the same as entering 0. Fortunately, there is a simple fix. In LOGIC.099, find the code that reads: <syntax type="C++">

if (said("tp")) {
    get.num("new room: ", v255);
    new.room.v(v255);
}

</syntax> Then change it to: <syntax type="C++">

if (said("tp")) {
    get.num("new room: ", v255);

    if (v255 == 0) {
        print("Can't tp to room 0");
    }
    else {
        new.room.v(v255);
    }
}

</syntax> Alternately, you can eliminate the "Can't tp to room 0" message and change the inner if statement to read: <syntax type="C++">

if (v255 != 0) {
    new.room.v(v255);
}

</syntax> This issue has also been corrected in the latest releases of the template game, available from http://www.agigames.com; however, AGI Studio may still be packaged with the buggy version of the template game.

Incorrect volume controls

The original versions of the template game attempted to control the sound volume by using the special variable v23 (or sound_volume in the template game.

Counterintuitively setting v23 to 0 produces the loudest sound and setting setting v23 to 15 produces no sound. The original template game assumed that the volume increased as the value of v23 increased, but this is not the case.

This issue has also been corrected in the latest releases of the template game, available from http://www.agigames.com; however, AGI Studio may still be packaged with the buggy version of the template game.

Related