K
Klonoa1545
Guest
Hi there. In my game, I want there to be a mechanic in which the player can absorb x amount of objects and then fire them off (something a la Kirby but not quite), but once the fired object collides with a wall, I want to create the same number of moving instances as there were objects absorbed. It's kind of hard to explain. Essentially this: My player object has trapped x objects. Upon release and then collision (against, say, a solid object), I want there to be a moving instance created for the same number of trapped objects. (3 trapped, 3 instances created upon collision). The only question is to whether or not I should use the for code or do until. From my reading, they are pretty much doing the same thing. Anywho, this is how I want to set up the code (specifically in a collision event):
//Whatever I'm going to call this script
{
var enemies_absorbed;
for ( enemies_absorbed = 3; i > 0; i -= 1)
{
var inst = instance_create(x+0, y+0, obj_movinginstance);
inst.direction = random(360);
inst.speed = 5;
}
}
In theory, this should do it, right? If I have three, it will subtract one from the counter until zero is reached, yeah? The alternative would be this (or something like it)
//Whatever I'm going to call this script
{
do
{
var inst = instance_create(x+0, y+0, obj_movinginstance);
inst.direction = random(360);
inst.speed = 5;
enemies_absorbed -= 1
}
until (enemies_absorbed = 0); }
I don't even know if these codes will work the way I've written them, but is there any consensus on which would be better?
Thanks. I'm a super-duper beginner, so any help is greatly appreciated!
//Whatever I'm going to call this script
{
var enemies_absorbed;
for ( enemies_absorbed = 3; i > 0; i -= 1)
{
var inst = instance_create(x+0, y+0, obj_movinginstance);
inst.direction = random(360);
inst.speed = 5;
}
}
In theory, this should do it, right? If I have three, it will subtract one from the counter until zero is reached, yeah? The alternative would be this (or something like it)
//Whatever I'm going to call this script
{
do
{
var inst = instance_create(x+0, y+0, obj_movinginstance);
inst.direction = random(360);
inst.speed = 5;
enemies_absorbed -= 1
}
until (enemies_absorbed = 0); }
I don't even know if these codes will work the way I've written them, but is there any consensus on which would be better?
Thanks. I'm a super-duper beginner, so any help is greatly appreciated!