                           THE  THIRD  DIMENSION

                    HOW YOU CAN USE PROCEDURES IN 3DKIT 2
                    -------------------------------------       

In this article I will try to explain how you can use procedures in a
lot of different and effective ways in Kit 2.
Accompanied with this textfile is a Kit 2 datafile for PC called:
Proc1.3wd and for the Amiga/Atari called Proca.3wd, together with:
Border1.lbm  for PC                      Bordera.iff for Amiga/Atari
Proc.3na     for PC (SB sound file)      Proc.3sm for Amiga/Atari

With this datafile + border + soundfile you can explore the effects
connected to the different procedures in test mode. In the freescape
editing window you can find out how they were made to work, together
with this article.

When you click on the General menu, you will find a submenu: Controls.
Click on it and you are in the control editor. As you know you are able
to set your movement controls with this editor, but you can also set
A PROCEDURE (or more) in the same way (by dragging and sizing a box in
your border, but also in the freescape area itself). In fact, you can 
use the whole screen to set procedures to buttons, icons, text or whatever.
And all that in the same way as you can set the movement controls. The
only limit is: you can use the SET COORDINATES for a PROCEDURE CONTROL
only ONCE in a datafile. That is the same with the movement controls by
the way. So if you set a procedure at coordinates 10 x by 40 y, these
coordinates will be occupied by that particular procedure from start till
end of your game (or project).

In order to use a lot of procedures in the way described above, you could
first decide how many movement controls you are going to need for your
game. As you probably don't need all of them, the rest of the controls can
be used for procedures.
So let's assume you will need 7 movement controls:
1. forward, 2. backward, 3. left, 4. right, 5 turn left, 6. turn right,
7. U-turn, 1 control for the activate function, 1 control for toggle 
sights and the ESC key to quit/startover. This is a total of 10. Then 
all the other controls could be used by procedures. 

When, by pressing next in the control editor, you have found a control you
do not need, click on it (to the right of FUNCTION) a couple of times until
the word PROCEDURE appears. Then you can type in a number to the right of
it, in this case type the number 1. You can then click on set and define
a box for it in your border (for instance on an icon) or even in the
freescape area itself (for instance on a cube or on text you have created
beforehand with the Pstring command.
Back in the control editor, you can choose which mousebutton to click with
on the button (icon). You can even assign a keyboard key to it (and this
last possibility can be very useful when you want to use a PASSWORD in your
game). In order to keep all the keys on your keyboard available, change
all the keys of the movement controls and the controls you only want to
be controlled with the mouse, into for instance a '.'. In this way no one
who knows the standard key controls in Kit2 can cheat in your game and 
you have all the letters available for other functions in procedures.

In the way described above, procedures can be set on coordinates on screen,
using all controls not necessary for movement. When you set another 
procedure, this will naturally be nr. 2 and upwards. But even if you need
to use more movement controls this will still allow you to set as many
procedure controls as you wish by just ADDING a new control button. Click
on the ADD BUTTON and you will get a new control with the function UNDEFINED.
Click on this word and all the standard control words will pop up, one after 
the other. Click on them until the word procedure appears and fill in an 
appropriate number.
When you are ready setting your procedures, you can quit the control
editor and go the Conditions menu to actually create and edit them.
In the Conditions menu click on Procedures, Create. Create as many as
you have set in the control editor. Then click on Procedures, Edit. Click
on procedure 1 and type in: 'sound (1)'. Test it out in test mode. When you
click on the appropriate button (icon) you should  hear a sound effect from 
the sound sample bank available at that moment.

In this way you can create and edit procedures to give all kinds of
effects on screen (see the accompanying datafile):
- animations, brushanimations, text, showing pictures, showing help text,
  going to another area, using passwords, using the Loadworld command
  etc., etc., in fact anything your imagination can come up with.
- You can also make menus with buttons to let people choose what
  they want. Make the menu in your paint package and in 3DKit2 locate and
  add it as a border. Set the smallest possible view window and colour
  area 1 in the same colour as the spot where your view window is placed
  in your border. Type c to get rid of the crosshair. Then set and add
  procedures to the buttons as described above.

Perhaps some PC members have seen some of the Living Books from Brotherbund
(Electronic Arts). They are aimed at children with educational elements
in it. They are gorgious to look at and a lot of fun to play with, no
matter what age you are. There are so many effects hidden in one picture,
which you can reveal by clicking on objects and buttons. Some of them
are hilarious and very funny to watch and listen to!
All this is possible in 3DKit2 too. Try out the various buttons in the
datafile and you will discover that a procedure is not only very simple
to define and use, but it is so powerful that you can create almost any
effect with it.

As for creating a PASSWORD, this will need a bit more explanation, which
I will try to make clear hereunder:
The first thing you need to know is the event in your world, when a
player activates or collides with something which gives him a password 
to proceed. If he doesn't have it he is unable to go further.
I have simplified this example in the datafile by activating (or colliding 
with) a pyrmid. The condition for this pyrmid is:
                      if activated?
                      or collided?                      
                      then
                      textfont (2)
                      textcol (6,7)
                      pstring ("Your password is -next-",80,110)
With the pstring command you can place text on every coordinate on your
screen.
This password contains 4 letters.
This means you have to set 4 procedures in the control editor in order 
for it to work correctly. But you don't have to set the controls for 
them on a visual button. You just have to define the correct keyboard key 
to each of them: the letter 'n' for the first procedure
                 the letter 'e' for the second    "
                 the letter 'x' for the third     "
                 the letter 't' for the fourth    "
Now create and edit the four procedures as follows:
Say the numbers are: 9,10,11 and 12.

Procedure 9:  sound (2)                        - key 'n'
Procedure 10: sound (3)                        - key 'e'
Procedure 11: sound (4)                        - key 'x'
Procedure 12: goto (1,4) another area or       - key 't'
              Loadworld ("myworld.3wd")
              (or whatever you want to let the player do next)

In this way your password consists in fact of only one EFFECTIVE letter,
i.e. the 't'. But one letter is not so attractive as a password. So the
above could give a solution for this.
And not only for a password! You can make riddles or puzzles in your
game, questions which the player has to answer before he can go on.
All in the same way as described for the password. So always have as
much keyboard keys for this available as you can by setting all the 
controls you use to one and the same letter or figure of the keyboard.
Except of course for the procedure controls you actually USE for keyboard
letters (such as a password).

Procedures can also be used within other conditions such as object, local
or general conditions. Then they sort of act like a subroutine that is
called on within the main condition, just like in Basic.
A simple example is given in the datafile: if you activate a cube you
can make it disappear and be replaced by for instance a pyrmid:
                        if activated?
                        then invis (3)
                        proc (13)
                        endif
Create and edit a procedure to let the pyrmid appear on the place where
the cube just vanished. Type in the procedure: vis (3).
This is a very simple way to use a procedure in an object condition. I'm
sure there will be lots of other more complex routines that can be made.

The third possibility to use a procedure is with sensors. In the datafile,
I followed the instruction on sensors, described in the Kit2 manual.
I created a cube and in its attributes menu I defined it a sensor, clicked
on sns and in the sensor menu I clicked to make it detect someone. I set
the range to 500. I clicked on proc and filled in the number 14. After
that I created and edited the procedure as follows: fadeout (4). Now
if you walk to that cube, the moment it senses you, it fades out. Here
again, you have lots of possibilities to use a procedure. Your imagination
is the only limit.

I wanted to use some real 3D letters and figures in my datafile. So I
created a 3D Alphabet including the numbers 1 to 9. I made this alphabet
in Kit 1 and you will also find it on disk with the extension .kit, so
it is suitable to use on all three computers in Kit1 and 2. So if you
don't already created one yourself, this might come in handy. By changing
the area scale the letters are big or at scale 12 even small. They are
made in area scale 2 (the default one).

I hope all the foregoing is clear enough and gives you another perspective
on what is possible with 3DKit 2. It creates a whole new way of making
interactive games in which the player could decide at a certain moment
which direction he is going, which includes the possibility of playing a 
game in more than one way! 

                                           Mieke
                         
                      

