Klick hier für die deutschsprachige Version.
At this column you can learn to create your own egg-O-shOOter.
|<<< What happens if >>>|
The housefly is flying and we can push it around the kitchen, but how can a hit trigger an event and so affect other objects?
Let's define a second object first. Copy the block of object number 1 and paste it below. Alter ObjectNumber to the value 2 (so that we really have a second object) and set ObjectStartActive to 0 (so that this object will appear later). Set ObjectVX/YMin/Max and ObjectMovePointing to 0. Therewith the second block should look like this:
ObjectNumber=2 #1#Fliege nach Treffer / Fly being hit
You can activate this second fly as soon as you hit fly number 1. This 'What happens if' construct is realized with the help of 'ObjectF' and 'ObjectD'. At ObjectD all Objects being DEactivated and at ObjectF all objects being activated are listed. Besides the event 'Hit', there are the events 'Range' and 'Time'. Let's have a look at the hit-event first. Objects being activated or deactivated during a 'hit'-event must have the character 'H' in front. We want to deactivate fly number 1 and activate fly number 2. So we have to set the variables of fly number 1 (!):
Try to hit the fly and observe what is happening.
Like planned, fly number 1 disappears and fly number 2 appears at the scene. The coordinates ObjectXMin/Max and ObjectYMin/Max of fly number 2 are identical to those of fly number 1 and so fly number 2 appears always at the top of the cooker wherever in the kitchen you hit fly number 1.
It was more realistic if fly number 2 would appear at the position of fly number 1. To achieve this we use the variable ObjectKoordPre, wherewith it is configured of which object the coordinates should be assumed. Fly number 2 should assume the actual coordinates of fly number 1 and so you have to set ObjectKoordPre=1 of fly number 2 (!).
Try to hit the fly again (don't forget to save 'themes.txt' and press 'N') and look what happens.
Apparently not what we expected! By setting ObjectKoordPre you configure from which object the coordinates should be assumed. The next step is to configure which variables should be assumed in which way. Egg-O-shOOter offers you different possibilities:
The underscore (_) indicates that the variables should be assumed without any modifications from the object given at ObjectKoordPre. If no ACTIVE object is found, the variable will be initialized by the values given at the right of the underscore (e. g. at game start).
The equal (=) means that the coordinates of the object given at ObejctKoordPre are ignored and the variable is newly initialized.
The 'greater than' (>) determines that the values are added to the coordinates of the object given at ObjectKoordPre.
The asterisk (*) determines that the values are multiplied with the coordinates of the given object.
You can use three of the given offers to achieve the wanted behavior. Use the underscore to ignore the values on the right of the underscore, or the greater than to add the value 0 or use the asterisk to multiply with the factor 1.
Useless is the equal, which ignores the coordinates of ObjectKoordPre.
Alter the lines with the X- and Y-coordinates of fly 2 (!) as followed:
Don't shoot immediately at the fly. Let it ascend for a while to see what's happening.
If you hit the fly, the second fly appears at the left below fly number 1 - why? Well, fly number 2 assumes the coordinates of fly number 1 and the values of ObjectXMin/Max and ObjectYMin/Max are added!
That gives you the chance to let following objects appear at a given distance to the parent object. Because of the fact that this isn't wanted here, you have to set those variables of fly number 2 (!) to zero.
If you set
the second fly also assumes the angle of rotation and the condition 'mirrored' of the parent fly.
Now fly number 2 appears at the position of the deactivated fly number 1 and stands still.
That doesn't look very realistic.
Set ObjectGravMin/Max to +20 (note the sign, it's 'bidirectional'!). That with you define gravitation pointing downwards. if you hit the fly, it stops and starts falling down. That is not realistic, but looks fine (like in a comic). But oops - what is happening down below? The fly bounces like a rubber ball and ascends again. That should be corrected. Alter the value of ObjectMoveType from 3 to 5. I am talking about fly number 2 (!) - number 1 is already deactivated. ObjectMoveType=3 caused fly number 2 to move inside the borders given by ObjectMoveXMin/Max and ObjectMoveYMin/Max. The value 5 commands the object to stop as soon as the area is left. Set ObjectMoveYMin=-150 and you will see that the fly stops short before reaching the upper edge of the bottom frame.
Try to alter ObjectVRotMin/Max, to let the fly rotate while moving downwards.
If you prefer a more realistic behavior, set the variables of fly number 2 (!) like down below:
Thatwith fly number 2 assumes the speed values of fly number 1 and the gravitation starts accelerating the fly downwards following a trajectory parabola. If you set ObjectHitDirection=0 at fly number 1 (!), the fly won't be deflected by the pea any longer.
By creating a new graphic of a hit fly and assuming this texture to fly number 2, you could complete this example - try it.
|<<<Back to moving objects Continue with range steering>>>|