Making a Toy for C3
A simple toy can be made by *anyone* ... even if you're not
an artist you can probably make something completely original
that has never been seen before!
Ok, if you're followed the other tutorials then you know the importance of having a unique classifier and how TARG is important. This tutorial will provide you with a working COS file and show you which bits you can alter and play with, to produce your very own agents.
Toys can be one of the simplest types of object you can make. There needs to be very little (if any!) interaction with other objects, all they need to do is take care of themselves and provide
a stimulus that will encourage creatures to play with them.For
this tutorial we will make something that animates and plays
a song when it is clicked on, using sprites and sounds that are already in the game. I'm going to use the graphics for the Meerk that lives in the desert terrarium ... if you open
up the sprite file called 'meerk.c16' you can see what it
looks like. We'll be using various frames from this file,
and animating them, just to show how easy animation is.
Here's
the file to download
If you
take this file and load it into the CAOS Tool you can alter
it yourself, making changes and getting to grips with making
your own toy.
| Code |
Explanation |
| ***create
the Meerk Toy |
� |
| inst |
Make
the rest of the instructions run in one tick (happens
automatically for injection scripts with the CAOS Tool
though, this is just a good habit to get into). Commands
that stop the script running all in one tick include:
slow, over, wait and endm |
| *create
one under the Norn garden |
� |
| new:
simp 2 21 1000 "Meerk" 0 0 5000 |
Create
a simple object with a classifier of family=2, genus=21
and species=1000. Family 2, Genus=21 shows that this is
a toy object.
The sprite file to use is called 'meerk', and you should
use all the images starting at 0. Put the finished creation
at image plane 5000. |
| attr
199 |
Give
it attributes of 199 - (gravity, boundaries, activateable,
pickupable) |
| *hand
can click on it - activate 1 |
� |
| clac
0 |
When
the hand clicks on it that will launch an activate 1 event |
| *can
be picked up, hit, activate1 and 2 |
� |
| bhvr
43 |
A
creature can pick it up, hit it, or activate 1 or 2 it. |
| accg
3 |
Acceleration
due to gravity = 3 |
| elas
0 |
Not
very elastic ... when it hits the floor 0 percent of it's
velocity remains |
| fric
100 |
High
friction ... will not slide down slopes. |
| pose
59 |
Use
image number 59 |
| puhl
-1 40 30 |
Define
a point on the object where it will be picked up from
(pickup handle). If you look in the sprite file you'll
see that each frame is 72x56 pixels. Therefore the point
(40,30) is slightly right and down of the centre of this
sprite. |
| mvto
1850 950 |
Move
to the position specified ... |
| cmrt
0 |
... and make the camera move to show you where that is. |
| � |
� |
| **activate
1 event |
� |
| scrp
2 21 1000 1 |
This
marks this chunk as being an activate 1 event script for
any object that has the classifier 2 21 1000. This will
be stored in the scriptorium. |
| clac
1 |
Next
time the hand clicks on this object it will launch an
activate 2 event. |
| stim
writ from 97 1 |
Give
a stimulus to whatever activated (this will be ignored
if the FROM object isn't a creature). Giving a stimulus
lets the creature learn lessons from this. Stim 97 is
the number you need to use for a toy, as it will reduce
boredom in most cases. |
| anim
[94 95 96 97 98 98 97 96 95 94 255] |
animate!
Use the frames specified, in order. The 255 at the end
means 'loop this sequence forever'. |
| sndc "mb_2" |
Play
a sounds effect from the object - Mb_2 happens to be a
sound effect from the music box but you can use any sound
file you like! |
| wait
130 |
wait
for a while (around 6-7 seconds). This allows the music
to finish playing before the toy changes pose (in the
next line) |
| pose
59 |
Go
back to the sitting down pose |
| endm |
End
of the activate 1 event script. |
| � |
� |
| **Activate
2 event |
� |
| scrp
2 21 1000 2 |
This
marks this chunk as being an activate 2 event script for
any object that has the classifier 2 21 1000. This will
be stored in the scriptorium. |
| stim
writ from 97 1 |
Same
stimulus as the activate 1 event |
| anim
[22 23 24 25 26 27 28 29 30 31 32 33 59] |
different
animation than before |
| setv
vely -15 |
Give
the object some velocity in an upward direction. |
| sndc "ct_1" |
Play
a sound effect |
| clac
0 |
Next
time the hand clicks on this object it will trigger an
activate 1 event |
| endm |
End
of the activate 2 event script |
| � |
� |
| **hit
event |
� |
| scrp
2 21 1000 3 |
This
marks this chunk as being a hit event script for any object
that has the classifier 2 21 1000. This will be stored
in the scriptorium. |
| stim
writ from 97 1 |
Same
stim as before |
| sndc "hit_" |
Play
a sound effect |
| anim
[70 71 72 73 74 75 76 77 78] |
Animate |
| over |
Do
not carry on with the rest of this script until the animation
has finished playing. In this case when the object reaches
pose 78 the script can carry on. |
| wait
10 |
Wait
a little while (about half a second) |
| pose
59 |
Change
pose back to sitting on the floor |
| endm |
End
of the hit script |
| � |
� |
| **pickup
event |
� |
| scrp
2 21 1000 4 |
This
marks this chunk as being a pickup event script for any
object that has the classifier 2 21 1000. This will be
stored in the scriptorium. |
| Pose
0 |
Change
pose |
| endm |
End
of the pickup script |
| � |
� |
| **drop
event |
� |
| scrp
2 21 1000 5 |
This
marks this chunk as being a drop event script for any
object that has the classifier 2 21 1000. This will be
stored in the scriptorium. |
| Pose
59 |
Change
pose |
| endm |
End
of the drop script |
| � |
� |
| ****REMOVAL |
A
remove script part is a very good habit to get into. It
allows you to easily remove all objects and their scripts
with the press of a button. |
| rscr |
This
is a special command that is only used by the CAOS Tool.
It marks the area below as being the remove script. This
section will only be injected by selecting the 'inject
remove script' from the CAOS Tool. |
| enum
2 21 1000 |
Enumerate
across all the objects that have a classifier of 2 21
1000 (in case you've forgotten this is the Meerk toy we've
just been making!) |
| kill
targ |
Kill
it |
| next |
Chose
the next meerk toy |
| scrx
2 21 1000 1 |
Remove
the activate 1 script for object 2 21 1000 |
| scrx
2 21 1000 2 |
Remove
the activate 2 script |
| scrx
2 21 1000 3 |
Remove
the hit script |
| scrx
2 21 1000 4 |
Remove
the pickup script |
| scrx
2 21 1000 5 |
Remove
the drop script |
| � |
� |
If you inject this COS file you will see the camera move to an area
just below the garden, and a small Meerk looking object will
fall to the floor. If you pick this up you will see that
it alters it's pose (and if you've got the sprite file open you should see that it changes to the first image in the file
- just as you'd expect with the drop script above injected!).
If you click on it you'll see it animate (it should start doing
press-ups) and a tune will play.
Next time you click on it it should jump up into the air
while animating and play a short sound effect.... and
that's it! You've created a simple toy.Using
this basic code there are many things you can alter to make
a completely new toy. Remember though to change the classifier
of the object unless you want to overwrite the existing scripts.
Some suggestions on areas you can change:
(1) Change the animations that are used in each event script (there
are plenty to choose from in the Meerk sprite file)
(2) Change the sound effects that are played - there are a
lot of sound effects in the sounds folder, try some of these
(3) Change the Sprite file used ... and make a new toy that
doesn't look like a Meerk. Some of the sprite files have
a
lot of frames of animation in them - especially the sprites
for the animals in the game. Try using 'graz', 'gnarl' or
'uglee' for some bizarre looking toys!
For the ultimate in creation, try drawing your own frames of animation
in a paint program and make them into a sprite file. You
can then make a toy that uses these graphics you have drawn.
Topic Keywords: agent caos creatures3 tutorials