885
edits
m (Created page with "{{AGIWiki}} '' NOTE: This text, originally by Rainer De Temple'' == Part 1 == === Introduction === By now no doubt you know what [[AGIWiki/AGI|AG...") |
m (syntax) |
||
Line 61: | Line 61: | ||
* 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: | ||
<syntax type="C++"> | |||
v200 = 4; | |||
load.pic(v200); | |||
</syntax> | |||
* 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 93: | Line 95: | ||
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: | ||
<syntax type="C++"> | |||
#include "defines.txt" | |||
</syntax> | |||
add | add | ||
< | <syntax type="C++"> | ||
#define your_object_name_with_no_spaces o1 | |||
</syntax> | |||
So it should read like this: | So it should read like this: | ||
< | <syntax type="C++"> | ||
#include "defines.txt" | |||
#define your_object_name_with_no_spaces o1 | |||
</syntax> | |||
The reason we use o1, is because ego, is always o0. | The reason we use o1, is because ego, is always o0. | ||
Line 110: | Line 117: | ||
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 | ||
<syntax type="C++"> | |||
if (new_room) { | |||
</syntax> | |||
and | and | ||
Line 118: | Line 125: | ||
We want to add our code after the line: | We want to add our code after the line: | ||
<syntax type="C++"> | |||
draw(ego); | |||
</syntax> | |||
The code we will add here displays a view on the screen: | The code we will add here displays a view on the screen: | ||
<syntax type="C++"> | |||
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. | |||
</syntax> | |||
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 160: | Line 167: | ||
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): | ||
< | <syntax type="C++"> | ||
#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>); | |||
</syntax> | |||
''' 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: | ||
<syntax type="C++"> | |||
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 | show.obj(220); // 220 is the number of the view with the | ||
// close-up and description of your item. | |||
} | |||
else { | |||
reset(input_parsed); | |||
} | |||
} | |||
</syntax> | |||
Also needing to be added is the code for getting the object: | Also needing to be added is the code for getting the object: | ||
<syntax type="C++"> | |||
if (said("get","<your item name>")) { | |||
if (has("<object name>")) { | |||
print("You already have it."); | |||
} | |||
else { | |||
reset(input_parsed); | |||
} | |||
} | |||
</syntax> | |||
''' 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: | ||
<syntax type="C++"> | |||
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 | |||
} | |||
} | |||
</syntax> | |||
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: | ||
<syntax type="C++"> | |||
if (said("look","<your item name>")) { | if (said("look","<your item name>")) { | ||
v255 = 2; | v255 = 2; | ||
Line 230: | Line 238: | ||
} | } | ||
} | } | ||
</syntax> | |||
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: | ||
<syntax type="C++"> | |||
draw(<your item name>); | draw(<your item name>); | ||
</syntax> | |||
to this: | to this: | ||
<syntax type="C++"> | |||
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>); } | ||
</syntax> | |||
[[Category:AGIWiki/Tutorials]] | [[Category:AGIWiki/Tutorials]] |
edits