By now no doubt you know what AGI is and you have downloaded AGI Studio by Peter Kelly. This tutorial or introduction to AGI game editing will show those who have little or no programming knowledge how to get started.
First, you must familiarize yourself with AGI Studio and what each button and menu item represents. Take the time to explore and experiment with each.
AGI games consist of 4 file types, or resources, all combined together into one file called vol.0 (or vol.x for multi-disk games). These file types are Picture, View, Sound, and Logic. The maximum amount of these in any AGI game is 256.
These are the background images for the game. They don't include anything that animates on the screen. The only time PictureS are changed is when the room changes. You can create picture resources with Lance Ewing's Picedit. The pictures are stored in vector format as opposed to bitmap format. This means that you can't create your pictures in your favorite graphics editor, because instead of storing the pixel data for the picture, it stores the actions taken to draw it. This was done to save considerable space. For example, imagine the size of a picture with a single line in bitmap format - 160x168 which would equal 26880 bytes on the disk in bitmap form with no compression. But if we were to store it in vector form, like normal, it would only take roughly 7 bytes, because it only stored the action to draw a line.
These are all of the animations or moving images in the game. They are generally small in dimensions, and unlike Picture resources, they are stored in bitmap form, with compression(RLE). They can have a maximum of sixteen colors from a fixed palette. One of these colors must be chosen to be transparent. When the View is drawn in the game, it will only display the colors that aren't transparent. The editing of View resources is done with the View editor built into AGI Studio. Each View contains up to 32 loops. Each loop contains a single animation, hence the name loop. The loops can have up to 32 cells each.
Important: It is important to know that when I mention bitmaps, I'm not referring to the Windows file type of BMP. Although BMP stands for bitmap, bitmap is a general term in graphics as well and describes the way an image is stored.
These are the sounds you hear in the game including music and sound effects. Each sound has three tracks, which can all play sound at the same time. This means that if you were writing music for your game, you could only have three instruments playing at once. For more info on creating sound resources consult the AGI message board.
These are the heart of an AGI game. An AGI game depends on at least one Logic resource, numbered 0. Each game cycle(every frame of the game) it reads this resource(ie number 0) and follows the actions or commands contained in it. Peter Kelly's Template game has the system set up slightly different. He has added Logic resources 90-95 and 98-99 which all handle different aspects of the game such as death, etc. These are all called each cycle from Logic 0, and return back to Logic 0 when finished. For a better understanding, it is best to examine the Template Game.
Inside a Logic resource, there are many types which you may use, these are the most common:
Variables (example v234 )
Variables may store a number up to 255. Variables v0 up to v26 are reserved.
Flags (example f56 )
Flags can have two states, set or not set. To set a flag, use the command set(flag number).
Objects (example o2 )
These are used to control animations on the screen. When a view is loaded, it is assigned to an object. To move the view around the screen, you must refer to the object number and not the view.
Objects are not to be confused with Inventory items, which are completely different.
Over the years I have followed AGI editing, a lot of the so-called demos that have been released have just been rehashes of the Template Game. They would only have one room, and one view - the player. This I believe is because it is very easy to work out how to print text, but these people couldn't work out how to create a new room. Well, it is actually quite simple.
Code:v200 = 4;
load.pic(v200);
That's basically how to create new rooms from the Template Game. Using this method you should be able to create as many rooms as you like.
Each part in this series will become more advanced. It is recommended you read part one before continuing.
NOTE: The work in this part is all done in a new game based on the template.
Creating an object to add to a room is very easy. First, you must understand that the AGI system needs to have a name for everything. In this case, it needs a name for your view. There are 256 names available from o0 to o255. When you end up having many objects in one room, it can become very confusing, which one is which. That is why we can define our own names for each object. You may have noticed already, that ego has been defined as o0. Many of the variables and flags have also been defined to have easier to remember names.
Adding your object name definition
So, to add your object definition, add this code to the room(in this case room 2 - Logic.002), just under the line:
Code:#include "defines.txt"
add
Code:#define your_object_name_with_no_spaces o1
So it should read like this:
Code:#include "defines.txt" #define your_object_name_with_no_spaces o1
The reason we use o1, is because ego, is always o0.
Initializing your object
Now, in the initialization section of the room, we decide which view we want to use for our object, and where we want to put it. The initialization section is everything between
if (new_room){
and
}
We want to add our code after the line:
Code:draw(ego);
The code we will add here displays a view on the screen:
Code:animate.obj(object name); //this tells the interpreter, that we're using this object load.view(2); //load the view we want to use into memory set.view(object name,2); //this assigns the view to the object we've created set.loop(object name,0); //set the current loop in the view to this value set.cel(object name,0); //set the current cel in the view to this value position(object name,43,104); //where to position the view on the screen. set.priority(object name,11); //set the priority of the object(change accordingly) ignore.objs(object name); draw(object name); //finally, draw the view on the screen.
Set.loop, set.cel, and set.priority aren't really necessary, but can be useful, if they need to be changed later on. Ignore.objs makes the object oblivious to other objects. If this is not set, then another object may stop if it hits this object when moving.
That's basically all there is to add an on-screen object. Remember, when using object commands, always refer to your object's name, and not the view number.
An Inventory item is one of the key elements to your AGI game. So unless you know how to add them, your game will be a flop.
There are many steps to adding an item to the game, and may seem daunting at first, but once you get the hang of it, it's very easy.
Creating the views for the Item
Each inventory item typically requires two views:
When you have done this, save the on-screen view as View.002 and the Inventory view as View.220. The inventory view may also have a description added.
Editing the OBJECT File
For the item(object) to be viewed in your inventory, it must have it's name put in the OBJECT file(not to be confused with onscreen objects). Just change object 1 to the name of your item, and the room number to the room in which it is found(2 in this case).
Putting the Item in the Room
After you have completed the first two steps, you are ready to add your Item to the room. This is done with the following code, added to the room: In the defines section(after the #include line):
Code:#define item name o1 //replace item name with your own. animate.obj(item name); load.view(2); set.view(item name,2); set.loop(item name,0); set.cel(item name,0); position(item name,43,104); //use your own position and priority here. set.priority(item name,11); ignore.objs(item name); stop.cycling(item name); draw(item name);
Modifying Logic.090
This logic, in the template game, handles non-room-specific functions, like get item and look item. Add this code under the section that says put various input responses here:
Code:if (said("look","your item name")) { // your item name must be replaced if (has("object name")) { // object name is the name you put in the OBJECT file show.obj(220); // 220 is the number of the view with the // close-up and description of your item. } else { reset(input_parsed); } }
Also needing to be added is the code for getting the object:
Code:if (said("get","your item name")) { if (has("object name")) { print("You already have it."); } else { reset(input_parsed); } }
Getting the item from the room
The above code was necessary for looking at the item in your inventory, or trying to get it if you already have it, but it's not good enough for getting the item from the specific room it's in. Use this code for that:
Code:if (said("get","your item name")) { v255 = 2; //obj.in.room only accepts variables if (obj.in.room("object name",v255)) { //so we make v255 equal to 2(the room number). if (posn(ego,37,111,51,124)) { //substitute these values with your own. print("Ok."); erase(your item name); get("object name"); } else { print("You're not close enough."); } } else { reset(input_parsed); // let logic 90 take care of it } }
Of course, we don't necessarily have to use v255, we can use any available Variable. The posn(ego,x1,y1,x2,y2) command, requires that x1,y1 is the top left corner of an imaginary box, and x2,y2 the lower right corner. Don't forget to enter the words you use into the WORDS.TOK file! This code is for looking at the item:
Code:if (said("look","your item name")) { v255= 2; if (obj.in.room("object name",v255)) { print("Here is where you describe the item in the room."); }else { reset(input_parsed); // let logic 90 take care of it }}
Finally, if you do not wish the item to be drawn when it isn't in the room(ie you have taken it), then replace the line above which said this:
Code:draw(your item name);to this:
Code:v255 = 2; if (obj.in.room("object name",v255)){draw(your item name); }
TopYou can help keep The Sierra
Help Pages and its affiliates alive by helping to defray some of the costs of hosting this site. If it has been of help to you, please consider contributing to help keep it online.Thank you.
The Sierra Help Pages | Sierra Game Help | Walkthroughs | Hints, Tips & Spoilers | Utilities | Links | SHP Forums | Search
© 2013 to present The Sierra Help Pages. All rights reserved. All Sierra games, artwork and music © Sierra.