885
edits
m |
m (syntax -> source) |
||
Line 15: | Line 15: | ||
=== Resources === | === Resources === | ||
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). | 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. | ||
==== PICTURE ==== | ==== PICTURE ==== | ||
Line 33: | Line 33: | ||
==== LOGIC ==== | ==== LOGIC ==== | ||
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. | 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: | Inside a LOGIC resource, there are many types which you may use, these are the most common: | ||
Line 39: | Line 39: | ||
''' Variables ''' '' (example ''<tt>v234</tt> '')'' | ''' Variables ''' '' (example ''<tt>v234</tt> '')'' | ||
Variables may store a number up to 255. | Variables may store a number up to 255. Variables v0 up to v26 are reserved. | ||
''' Flags ''' '' (example ''<tt>f56</tt> '')'' | ''' Flags ''' '' (example ''<tt>f56</tt> '')'' | ||
Flags can have two states, set or not set. | Flags can have two states, set or not set. To set a flag, use the command <tt>set(flag number)</tt>. | ||
''' Objects ''' '' (example ''<tt>o2</tt> '')'' | ''' Objects ''' '' (example ''<tt>o2</tt> '')'' | ||
These are used to control animations on the screen. | 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. | ||
=== Creating a new room from the Template Game === | === Creating a new room from the Template Game === | ||
Line 53: | Line 53: | ||
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. | 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. | ||
* First you will have to create the PICTURE resource for the room. | * First you will have to create the PICTURE resource for the room. Once created, add this to the game using the menu RESOURCE-ADD. Browse to the PICTURE and press OK. Set the resource number to 3 and make sure that the resource type is PICTURE. | ||
* Now that this is done, all that we have to do is create the logic. | * Now that this is done, all that we have to do is create the logic. The best thing to do is just copy and paste from LOGIC.002. So, double click on LOGIC.002 in AGI Studio. An editing screen will appear with the source code for room 2. Drag the mouse button from the top of the file to the bottom to select all of the text. From the edit menu, select COPY. Now close this file, and start a new one, by clicking on the button labeled Logic editor on the toolbar. Select PASTE from the edit menu. | ||
* At the top of the file are 5 comment lines. All comment lines begin with "//". You may delete these or change it to suit this new room(3). | * At the top of the file are 5 comment lines. All comment lines begin with "//". You may delete these or change it to suit this new room(3). | ||
* Next, comes an if statement. This statement checks if we just entered the room. | * Next, comes an if statement. This statement checks if we just entered the room. The flag new_room will be set if we did. Everything after the brace( { ) will be done until we get to the closing brace for the if statement ( } ). | ||
* First the picture of the room number is loaded into memory, using the load.pic(room_no) command. Keep in mind that every command has either a semi-colon(;) at the end or an opening brace. In this case, it’s a semi-colon. If you wish to change the number of the PICTURE resource which is loaded, you must first set a variable(say, v200) to that value and invoke the command like this: | * First the picture of the room number is loaded into memory, using the load.pic(room_no) command. Keep in mind that every command has either a semi-colon(;) at the end or an opening brace. In this case, it’s a semi-colon. If you wish to change the number of the PICTURE resource which is loaded, you must first set a variable(say, v200) to that value and invoke the command like this: | ||
< | <source lang="cpp"> | ||
v200 = 4; | v200 = 4; | ||
load.pic(v200); | load.pic(v200); | ||
</ | </source> | ||
* discard.pic(room_no) just rids the PICTURE from memory once it is drawn. | * discard.pic(room_no) just rids the PICTURE from memory once it is drawn. | ||
Line 97: | Line 97: | ||
So, to add your object definition, add this code to the room(in this case room 2 - LOGIC.002), just under the line: | So, to add your object definition, add this code to the room(in this case room 2 - LOGIC.002), just under the line: | ||
< | <source lang="cpp"> | ||
#include "defines.txt" | #include "defines.txt" | ||
</ | </source> | ||
add | add | ||
< | <source lang="cpp"> | ||
#define your_object_name_with_no_spaces o1 | #define your_object_name_with_no_spaces o1 | ||
</ | </source> | ||
So it should read like this: | So it should read like this: | ||
< | <source lang="cpp"> | ||
#include "defines.txt" | #include "defines.txt" | ||
#define your_object_name_with_no_spaces o1 | #define your_object_name_with_no_spaces o1 | ||
</ | </source> | ||
The reason we use o1, is because ego, is always o0. | The reason we use o1, is because ego, is always o0. | ||
Line 119: | Line 119: | ||
Now, in the initialisation section of the room, we decide which view we want to use for our object, and where we want to put it. The initialisation section is everything between | Now, in the initialisation section of the room, we decide which view we want to use for our object, and where we want to put it. The initialisation section is everything between | ||
< | <source lang="cpp"> | ||
if (new_room) { | if (new_room) { | ||
</ | </source> | ||
and | and | ||
Line 127: | Line 127: | ||
We want to add our code after the line: | We want to add our code after the line: | ||
< | <source lang="cpp"> | ||
draw(ego); | draw(ego); | ||
</ | </source> | ||
The code we will add here displays a view on the screen: | The code we will add here displays a view on the screen: | ||
< | <source lang="cpp"> | ||
animate.obj(object name); //this tells the interpreter, that we're using this object | 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 | load.view(2); //load the view we want to use into memory | ||
Line 141: | Line 141: | ||
ignore.objs(object name); | ignore.objs(object name); | ||
draw(object name); //finally, draw the view on the screen. | draw(object name); //finally, draw the view on the screen. | ||
</ | </source> | ||
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. | 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. | ||
Line 169: | Line 169: | ||
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): | 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): | ||
< | <source lang="cpp"> | ||
#define item name o1 //replace item name with your own. | #define item name o1 //replace item name with your own. | ||
animate.obj(item name); | animate.obj(item name); | ||
load.view(2); | load.view(2); | ||
Line 182: | Line 182: | ||
stop.cycling(item name); | stop.cycling(item name); | ||
draw(item name); | draw(item name); | ||
</ | </source> | ||
''' Modifying LOGIC.090 ''' | ''' 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: | 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: | ||
< | <source lang="cpp"> | ||
if (said("look","your item name")) { // your item name must be replaced | 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 | if (has("object name")) { // object name is the name you put in the OBJECT file | ||
Line 196: | Line 196: | ||
} | } | ||
} | } | ||
</ | </source> | ||
Also needing to be added is the code for getting the object: | Also needing to be added is the code for getting the object: | ||
< | <source lang="cpp"> | ||
if (said("get","your item name")) { | if (said("get","your item name")) { | ||
if (has("object name")) { | if (has("object name")) { | ||
Line 207: | Line 207: | ||
} | } | ||
} | } | ||
</ | </source> | ||
''' Getting the item from the room ''' | ''' 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: | 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: | ||
< | <source lang="cpp"> | ||
if (said("get","your item name")) { | if (said("get","your item name")) { | ||
v255 = 2; //obj.in.room only accepts variables | v255 = 2; //obj.in.room only accepts variables | ||
Line 228: | Line 228: | ||
} | } | ||
} | } | ||
</ | </source> | ||
Of course, we don't necesarily 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: | Of course, we don't necesarily 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: | ||
< | <source lang="cpp"> | ||
if (said("look","your item name")) { | if (said("look","your item name")) { | ||
v255 = 2; | v255 = 2; | ||
Line 240: | Line 240: | ||
} | } | ||
} | } | ||
</ | </source> | ||
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: | 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: | ||
< | <source lang="cpp"> | ||
draw(your item name); | draw(your item name); | ||
</ | </source> | ||
to this: | to this: | ||
< | <source lang="cpp"> | ||
v255 = 2; | v255 = 2; | ||
if (obj.in.room("object name",v255)) { draw(your item name); } | if (obj.in.room("object name",v255)) { draw(your item name); } | ||
</ | </source> | ||
[[Category:AGIWiki/Tutorials]] | [[Category:AGIWiki/Tutorials]] |
edits