Difference between revisions of "AGIWiki/Creating an AGI Game"

Jump to navigation Jump to search
m (syntax)
m (syntax indeed)
Line 51: Line 51:
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.  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.
* 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.  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.
* 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.
Line 130: Line 130:
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++">
<syntax type="C++">
animate.obj(&lt;object name&gt;);        //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
set.view(&lt;object name&gt;,2);        //this assigns the view to the object we've created
set.view(object name,2);        //this assigns the view to the object we've created
set.loop(&lt;object name&gt;,0);        //set the current loop in the view to this value
set.loop(object name,0);        //set the current loop in the view to this value
set.cel(&lt;object name&gt;,0);          //set the current cel in the view to this value
set.cel(object name,0);          //set the current cel in the view to this value
position(&lt;object name&gt;,43,104);    //where to position the view on the screen.
position(object name,43,104);    //where to position the view on the screen.
set.priority(&lt;object name&gt;,11);    //set the priority of the object(change accordingly)
set.priority(object name,11);    //set the priority of the object(change accordingly)
ignore.objs(&lt;object name&gt;);
ignore.objs(object name);
draw(&lt;object name&gt;);              //finally, draw the view on the screen.
draw(object name);              //finally, draw the view on the screen.
</syntax>
</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 168: Line 168:


<syntax type="C++">
<syntax type="C++">
#define &lt;item name&gt; o1        //replace &lt;item name&gt; with your own.
#define item name o1        //replace item name with your own.
    
    
animate.obj(&lt;item name&gt;);
animate.obj(item name);
load.view(2);
load.view(2);
set.view(&lt;item name&gt;,2);
set.view(item name,2);
set.loop(&lt;item name&gt;,0);
set.loop(item name,0);
set.cel(&lt;item name&gt;,0);
set.cel(item name,0);
position(&lt;item name&gt;,43,104);  //use your own position and priority here.
position(item name,43,104);  //use your own position and priority here.
set.priority(&lt;item name&gt;,11);
set.priority(item name,11);
ignore.objs(&lt;item name&gt;);
ignore.objs(item name);
stop.cycling(&lt;item name&gt;);
stop.cycling(item name);
draw(&lt;item name&gt;);
draw(item name);
</syntax>
</syntax>
''' Modifying LOGIC.090 '''
''' Modifying LOGIC.090 '''
Line 185: Line 185:
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++">
<syntax type="C++">
if (said("look","&lt;your item name&gt;")) {  // &lt;your item name&gt; must be replaced
if (said("look","your item name")) {  // your item name must be replaced
   if (has("&lt;object name&gt;")) {          // &lt;object name&gt; is the name you put in the OBJECT file
   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.
                                         // close-up and description of your item.
Line 197: Line 197:
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++">
<syntax type="C++">
if (said("get","&lt;your item name&gt;")) {
if (said("get","your item name")) {
   if (has("&lt;object name&gt;")) {
   if (has("object name")) {
     print("You already have it.");
     print("You already have it.");
   }
   }
Line 210: Line 210:
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++">
<syntax type="C++">
if (said("get","&lt;your item name&gt;")) {
if (said("get","your item name")) {
   v255 = 2;                                //obj.in.room only accepts variables
   v255 = 2;                                //obj.in.room only accepts variables
   if (obj.in.room("&lt;object name&gt;",v255)) {  //so we make v255 equal to 2(the room number).
   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.
     if (posn(ego,37,111,51,124)) {          //substitute these values with your own.
       print("Ok.");
       print("Ok.");
       erase(&lt;your item name&gt;);
       erase(your item name);
       get("&lt;object name&gt;");
       get("object name");
     }
     }
     else {
     else {
Line 229: Line 229:
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++">
<syntax type="C++">
  if (said("look","&lt;your item name&gt;")) {
  if (said("look","your item name")) {
   v255 = 2;
   v255 = 2;
   if (obj.in.room("&lt;object name&gt;",v255)) {
   if (obj.in.room("object name",v255)) {
     print("Here is where you describe the item in the room.");
     print("Here is where you describe the item in the room.");
   }
   }
Line 241: Line 241:
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++">
<syntax type="C++">
  draw(&lt;your item name&gt;);
  draw(your item name);
</syntax>
</syntax>
to this:
to this:
<syntax type="C++">
<syntax type="C++">
  v255 = 2;
  v255 = 2;
  if (obj.in.room("&lt;object name&gt;",v255)) { draw(&lt;your item name&gt;); }
  if (obj.in.room("object name",v255)) { draw(your item name); }
</syntax>
</syntax>
[[Category:AGIWiki/Tutorials]]
[[Category:AGIWiki/Tutorials]]