Difference between revisions of "Making AGI Games Part 1"

From AGI Wiki
Jump to navigationJump to search
Line 3: Line 3:
 
<div align="center">
 
<div align="center">
 
Page:
 
Page:
[[Making AGI Games|1]] |  
+
[[Making AGI Games Part 1|1]] |  
 
[[Making AGI Games Part 2|2]]
 
[[Making AGI Games Part 2|2]]
 
</div><br />
 
</div><br />
Line 145: Line 145:
 
<div align="center">
 
<div align="center">
 
Page:
 
Page:
[[Making AGI Games|1]] |  
+
[[Making AGI Games Part 1|1]] |  
 
[[Making AGI Games Part 2|2]]
 
[[Making AGI Games Part 2|2]]
 
</div><br />
 
</div><br />

Revision as of 12:19, 26 December 2013

Tutorials and Guides Table of Contents

Page: 1 | 2


Making AGI Games

By Peter Kelly

Originally published on the old Adventure Collective site, January 21 2000

 

 
Introduction

AGI (Adventure Game Interpreter) is a game engine written by Sierra On-Line in the early 1980s. It was used to create a number of their early adventure games such as King's Quest: Quest for the Crown, King's Quest II: Romancing the Throne, King's Quest III: To Heir is Human, and Police Quest: In Pursuit of the Death Angel. AGI supported only fairly primitive graphics by today's standards (160x200 pixels in 16 colors) and used a text based interface where the player entered actions to perform in the game. The player could also move their character around on screen using the arrow keys.

Despite these limitations, AGI was fairly revolutionary at the time. It used a number of design ideas rarely, if ever, seen before in adventure games. The most advanced of these was the ability to provide a pseudo-3D look to scenes in the game by allowing the player's character to stand in different parts of the screen behind some objects and in front of others. This is, of course, a far departure of the definition of 3D we used nowadays. Nevertheless, AGI provided facilities for animation of characters and objects in the game, in contrast to the static screens of the earlier generation. As such, the purpose of this feature series is to describe what has happened with AGI since the days when it was used by Sierra On-Line.
 

King's Quest III: To Heir is Human

 

What's so special about AGI?

AGI is remembered by many adventure game enthusiasts because it was used by many of the early "classic" adventure games. All the first King's Quest, Police Quest, Space Quest, and Leisure Suit Larry games used this interpreter.

In recent years, there has been some interest in the technical aspects of AGI--that is, how the interpreter works and how to view and edit games that use the interpreter. In late 1996, having been an adventure game fan (particularly of Sierra On-Line) for a number of years, I became interested in the inner workings of AGI. I originally started off by examining some of the files in King's Quest II: Romancing the Throne and working out what format they were stored in. I then wrote a program called AGIHACK which would display some of the graphics from the games. Not long after that I met some other people who had been doing similar things, and we started working together on figuring out the file formats.

After we had worked out most of this information, I started work on a program called AGI Studio. My goal was to write a program which would let you view and edit all of the resources in AGI games, as well as create your own AGI games. AGI Studio never got completely finished, but with the help of a couple of other programs you can use it to create your own AGI games!
 

AGI Studio
AGI Studio

 

How do AGI Games Work?

Each AGI game consists of a number of scenes (called rooms). These are a fairly standard part of any adventure game. The player controls a character (called ego) which moves around the screen and can perform all sorts of actions like picking up items, opening doors, and talking to other characters in the game. Each room has a background picture and a script (called a logic) which governs what can happen in the room. The logic is written in a C-like language which is compiled into a bytecode and executed by the interpreter. Games can also contain views (animations, still images of game characters, and other graphics that are not part of the background picture) and sounds (3-voice music tracks).

In addition to the above components, a game will generally have a number of other logics which control various other aspects of the game, such as setting up menus, displaying the help screen, and responding to miscellaneous player requests such as saving or loading a game.

Let's look at an example room. The screenshot below shows room 2 from King's Quest: Quest for the Crown. This room contains three main things: a castle, a moat, and a bridge. The player can walk around the room, look at various parts of it, cross the bridge, open the castle doors, or fall in the moat and get eaten!
 

Room 2, King's Quest: Quest for the Crown
Room 2, King's Quest: Quest for the Crown


By looking through the source code at the logic for this room, you should be able to get a fair idea of what the script is doing, especially if you are experienced in programming languages like C, Pascal or Java.

You will notice that a lot of the code looks like this:

Code:

<syntaxhighlight lang="agi"> if (said("look","water")) { print("It's your typical moat water: murky and smelly."); } </syntaxhighlight>

This is one of the most simple examples of logic code, and you can see statements like this in just about any room in the game. What it does is to check if the player said "look water," and if so, display a message in response which comes up in a window on the screen.

A variation of the above code looks like this:

Code:

<syntaxhighlight lang="agi"> if (said("look","door")) { if (posn(ego,0,120,159,167)) { print("These doors are strongly built to keep out unwanted visitors."); } else { print("You can't see them from here."); } } </syntaxhighlight>

When the player types "look door," the response they get will depend on where they are standing. If their coordinates on the screen are between (0,120) and (159,167), they will see a description of the doors. Otherwise, they will be told "You can't see them from here."

This code is fine for looking at things. But what if we want to add a little interactivity? Here is a simplified version of the code that is run when the player tries to enter the castle:

Code:

<syntaxhighlight lang="agi"> if (said("open","door")) { if (posn(ego,105,120,121,128)) { start.update(doors); sound(15,f28); end.of.loop(doors,f24); stop.motion(ego); set.priority(ego,15); print("The huge doors swing open slowly."); score += 1; } else { print("You cannot reach the door from here."); } } </syntaxhighlight>

First, the game checks that the player is in near enough to the door. If so, a number of commands are executed to display the animation of the doors opening and the player walking through them:

start.update(doors); Enable animation of the doors
sound(15,f28); Play sound 15 and when finished set flag 28
end.of.loop(doors,f24); Play an animation of the doors opening and when finished set flag 24
stop.motion(ego); Stop ego from moving
set.priority(ego,15); Make sure ego gets drawn on top of everything else
print("The huge doors swing open slowly.");   Display a message to the user
score += 1; Add 1 point to the player's score

 

Once the sound and animation have finished, two flags will be set: 24 and 28. When both of these are set, the following code gets run, which takes the player to room 55 (inside the castle):

Code:

<syntaxhighlight lang="agi"> if (isset(f24) && isset(f28)) { new.room(55); } </syntaxhighlight>

Note that flags are the same as Boolean variables in other languages. They can have two values, true or false. In AGI these values are known as set and unset.

I hope this section has given you an overview about how an AGI game works. In Part II of this article series, I'll show you how you can actually get access to the source code and resources that make up an AGI adventure game.

 

Page: 1 | 2


Tutorials and Guides Table of Contents

< Previous: Chapter 1Next: Making AGI Games Part 2 >