For simple drops where the 'hurt object' doesn't change shape then the basic 'apple drop' code works well and I've added full details below. For more complicated acid drops where the drop changes shape before it drops and splashes as it hits the ground, then as well as 007's suggestion, you can unpack my 'Almost Spellbound Dizzy' and search for 'acid' in the game.gs file.
Apple Drops
To make objects such as apples drop down, disappear and then reappear at the starting point after a pause
is quite involved, but all you need to do is add the generic function (AppleDrop) to the Game.gs file.
This is coded in such a way that it will automatically pick up any dynamic object you set as a falling apple
on the map and you just need to activate each one with a simple line in the UpdateRoom function
for each room with a falling apple or apples.
It's also important to set the 'delay' rate for each apple on the map as the 'delay' line in the function
determines the pause before the apple starts to drop again. A good starting point is '50', but you can
change that to whatever suits your purposes. That way you can have apples falling at different times
in the same room.
Most important of all is to make sure the 'y' positions you set for where the apple starts
and where it finishes are divisible by the 'drop speed' or it won't work. Using y+=2 means
that if the top 'y' position is an odd number ie, 1325 then the bottom 'y' position must be an
odd number (divisible by 2). Likewise if the top position is an even number, set the lower
'y' position to an even number.
Cosmetically, it is also quite good to have the 'layer' of the apple lower then the place where
it starts and ends. That way it seems to disappear into the ground and if it starts behind a
clump of leaves on a tree will fall from behind the leaves.
////////////////////////////
The moving apple should be dynamic and start at status = 1, so that it starts to move as soon
as you enter the room. Set the 'delay' of the moving object to determine the time that the object
pauses at the end of it's run. You can also add hurt and death characteristics to both of the objects
..or even 'jump' so that it bumps Dizzy.
To add new apples, place them on the map then add a new room update with the correct numbers.
/////////////////////////////////
Just copy this function, the id, dtop and dbot will be determined by the room update
func AppleDrop (id,dtop,dbot)
{
idx = ObjFind(id);
if (ObjGet(idx, O_STATUS) == 0)
{
if (!IsUpdate(ObjGet(idx, O_DELAY)))
return;
ObjSet (idx, O_DISABLE, 0);
ObjSet (idx, O_STATUS, 1);
}
if (ObjGet (idx, O_STATUS) == 1)
{
y=ObjGet (idx, O_Y);
y+=2;
ObjSet (idx, O_Y,y);
ObjPresent(idx);
if (y==dbot)
{
ObjSet (idx, O_STATUS, 0);
ObjSet (idx, O_DISABLE, 1);
ObjSet (idx, O_Y, dtop);
}
}
}
////////////////////////////////////////
func UpdateRoom_2_1()
{
AppleDrop(1000,152,242);
}
For this example, the falling apple is in room 2_1, the ID is 1000, the starting y position is 152 and the
finishing y position is 242 (matching numbers remember).