S
shrunkenmaster
Guest
I have a pickup/drop object issue that I need some help with.
The player must pick up an object (oCapPickup) from the central 'bin' and drop it on one of the multiple random places, designated by the oCapGhost objects. Then the player needs to pick up another from the bin, and so on.
This all works ok with one Ghost object, but not if I increase the amount (variable pn) to 2 or more. I've played around with a few things but I think I'm missing something.
oInitCapacitor (create)
oCapPickup ( collision with oCapGhost)
Hope my desciption makes sense - any help would be great.
The player must pick up an object (oCapPickup) from the central 'bin' and drop it on one of the multiple random places, designated by the oCapGhost objects. Then the player needs to pick up another from the bin, and so on.
This all works ok with one Ghost object, but not if I increase the amount (variable pn) to 2 or more. I've played around with a few things but I think I'm missing something.
oInitCapacitor (create)
Code:
//draw ghost caps
pn = path_get_number(cap_path); //get number of points on the path
pn = 2; //TEST NUMBER
capsleft = pn;
for (var n = 0; n <pn; n++)
{
pp = irandom_range (1, pn); //choose random point
px = path_get_point_x(cap_path, pp); //set x
py = path_get_point_y(cap_path, pp); //set y
if (!place_meeting(px,py,oCapGhost)) // check position free and create ghost
{
with instance_create_layer(px, py, "Pickup", oCapGhost)
{
image_index = 3;
image_speed = 0;
}
}
}
// draw cap in bin (this one doesn't get picked up)
global.cap_col = irandom (2);
with instance_create_layer(248, 350, "Pickup", oCapBin)
{
image_index = global.cap_col;
image_speed = 0;
}
// draw cap to pick up
with instance_create_layer(248, 350, "Pickup", oCapPickup)
{
image_index = oCapBin.image_index
image_speed = 0;
}
Code:
if ((global.carrying = true) && (other.image_index =3) && (oInitCapacitor.capsleft >0))
{oInitCapacitor.capsleft -=1;
other.image_index = global.cap_col;
global.carrying = false;
if(oInitCapacitor.capsleft >0)
{
oCapPickup.x = 248;
oCapPickup.y = 250;
}
else instance_destroy();
}