• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Many many Bullets

W

Wild_West

Guest
Has anyone here ever played the game Furi?
I'm trying to replicate a bullet hell style of shooting like the one in that game but I can't seem to figure out how to work with all the instances I create because I just get errors that the ones with names I give don't exist.
I know I need to use a loop to make x amount of bullet instances and id them all with a variable name new_bullet_0 new_bullet_1 ect but I don't know how without just like, tagging the last one made.
Any help with looping would be appreciated, so I can actually understand what I need to do.
 

samspade

Member
Has anyone here ever played the game Furi?
I'm trying to replicate a bullet hell style of shooting like the one in that game but I can't seem to figure out how to work with all the instances I create because I just get errors that the ones with names I give don't exist.
I know I need to use a loop to make x amount of bullet instances and id them all with a variable name new_bullet_0 new_bullet_1 ect but I don't know how without just like, tagging the last one made.
Any help with looping would be appreciated, so I can actually understand what I need to do.
I'm not quite sure what you're asking here. I did look up a video of Furi. It seems like you just want enemies that can shoot a lot of bullets in a single frame? Maybe have those bullets know who shot them?

Code:
///whatever creates bullets, probably step or alarm
if (instance_exists(target)) {
    var angle = point_direction(x, y, target.x, target.y) - 25;
    repeat (10) {           
        var xx = lengthdir_x(5, angle);
        var yy = lengthdir_y(5, angle);                                     
        with (instance_create(x + xx, y + yy, obj_bullet)) {
            parent = other.id;
        }
        angle += 5;
    }
}
Again, this is only one example. You could accomplish the same thing with a for loop or a while loop for example. And I just made up one bullet pattern and saved the shooter object's id to the bullet object.
 
Last edited:
W

Wild_West

Guest
I'm not quite sure what you're asking here. I did look up a video of Furi. It seems like you just want enemies that can shoot a lot of bullets in a single frame? Maybe have those bullets know who shot them?

Code:
///whatever creates bullets, probably step or alarm
if (instance_exists(target)) {
    var angle = point_direction(x, y, target.x, target.y) - 25;
    repeat (10) {          
        var xx = lengthdir_x(5, angle);
        var yy = lengthdir_y(5, angle);                                    
        with (instance_create(x + xx, y + yy, obj_bullet)) {
            parent = other.id;
        }
        angle += 5;
    }
}
Again, this is only one example. You could accomplish the same thing with a for loop or a while loop for example. And I just made up one bullet pattern and saved the shooter object's id to the bullet object.
I didn't even think to use the lengthdir functions :p
But I will now. Question though, why the other.id assign for parent? unless this is a collision event I don't think other even works does it?
 
E

elementbound

Guest
In a with loop, you can use other to access the instance you started off with. So for example if you have object A and object B, and this code in one of object A's event:
Code:
// id here is an instance of A
with(B) {
    // id here is an instance of B
    // other.id here is the above instance of A
}
 
Btw, if you want to iterate through a list of items and give them all an id, you should use a for loop and an array:
Code:
for (var i=0;i<num_instances;i++) {
   instance_array[i] = instance_create(x,y,object);
}
Then you can just use instance_array[0], instance_array[1], etc to identify the individual instances.
 

samspade

Member
I didn't even think to use the lengthdir functions :p
But I will now. Question though, why the other.id assign for parent? unless this is a collision event I don't think other even works does it?
You can use other in a with statement. So other.id is the id of the object instance using the with statement. You may not need to do this here, but I use it a lot to save which object created the new object. Say for some reason another object needs to know which instance shot that particular bullet.
 
W

Wild_West

Guest
In a with loop, you can use other to access the instance you started off with. So for example if you have object A and object B, and this code in one of object A's event:
Code:
// id here is an instance of A
with(B) {
    // id here is an instance of B
    // other.id here is the above instance of A
}
I'm still not sure I get it, I'd probably have to see it used in a specific code for something.
I mean I use with statements all the time just not in that way
 
Top