Compount Parts - PAT:DULL

DULL parts are used to create areas of an image that can be animated independently of the main object.

Here is a simple example, using the BeatBox music box from the game (open up the sprite file called 'beatbox.c16' to follow this example).

This example is not the same as the BeatBox ... it has been simplified to illustrate DULL parts only.

CodeExplanation
***Beat box 
inst 
*create one near the hatchery 
new: comp 2 21 1234 "beatbox" 11 0 5000Create a new Compound Object, with a classifier of 2 21 1234. It will use 11 images from the sprite file called BeatBox, with those 11 images starting at 0 in the file. The image plane for this object is 5000
*create the light display 
pat: dull 1 "beatbox" 11 21 0 0Create a DULL part, with part number = 1. Use the BeatBox sprite file, but start the image count at image number 11. This part has a relative coordinate of (21,0) with respect to the coordinates of part 0. The relative plane of this part is 0, with respect to the plane of part 0.
*create the on off button (not a button!) 
pat: dull 2 "beatbox" 15 31 13 0Create a DULL part, with part number = 2. Use the BeatBox sprite file, but start the image count at image number 15. This part has a relative coordinate of (31,13) with respect to the coordinates of part 0. The relative plane of this part is 0, with respect to the plane of part 0.
  
attr 199Give attributes
clac 0Clicking will trigger an activate 1 event
elas 0Define physical property
fric 100Define physical property
perm 60Define physical property
accg 5Define physical property
mvto 1500 900Move to underneath the garden ...
cmrt 0.. and move the camera too

Download the COS file at the bottom of this article.

This has created an agent with 3 parts - part 0 is the main BeatBox (with 11 images), part 1 is the strip of lights across the top of the BeatBox (notice that for DULL parts the number of images is not specified ... all we define is the starting image) and part 2 is the button in the middle of the BeatBox.

Now this object has been created we can define some event scripts for it, the COS file for download contains these events already ... but here they are explained:

CodeExplanation
**beatbox activate 1 
scrp 2 21 1234 1 

part 0

change to part 0 ...
anim [0 1 2 3 4 5 6 7 8 9 10 255]... and animate it using frames 0-10, repeat.
clac 1change CLAC mode so that next click by the hand produces an activate 2 event
endm 
  
**beatbox activate 2 
scrp 2 21 1234 2 
part 1change to part 1 ...
anim [0 1 2 3 255]... and animate it using frames 0-3, repeat.
clac 2change CLAC mode so that next click by the hand produces a deactivate event
endm 
  
**beatbox deactivate 
scrp 2 21 1234 0 
part 2change to part 2 ...
anim [0 1 255]... and animate it using frames 0-1, repeat.
clac 3change CLAC mode so that next click by the hand produces a hit event
endm 
  
**beatbox hit 
scrp 2 21 1234 3 
part 0change to part 0 ...
pose 0.. and put it in pose 0
part 1change to part 1 ...
pose 0... and put it in pose 0
part 2change to part 2 ...
pose 0... and put it in pose 0
clac 0change CLAC mode so that next click by the hand produces an activate 1 event
endm 

This object when clicked on will first animate part 0, next click will animate part 1, next click will animate part 2 and the final click will stop all of the parts animating.

The key things to notice here are that with a Compound Object you need to specify which part you are referring to whenever you perform an animation command such as ANIM or POSE. This is achieved using the PART command.

Also note that making one part animate has no effect on any other part ... this is the key use for a DULL part.


Downloads:   COS File