• 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!

GameMaker (SOLVED) Having a script check every step by it's own

  • Thread starter Erick is not unique
  • Start date
E

Erick is not unique

Guest
hello! Pre beginner coding enthusiast here!

So i've been triying to create a script that can basically allow me to spawn "bullet hell" type proyectiles with simple trayectories to avoid the use of bullet generators that spawn and get destroyed via alarms. So that i can pretty much fill up scr(object,speed, direction, quantity, spacing, xpos, ypos) easily.

Problem is that "quantiy" is spawning N number of instances in a single frame, rather than every step event.

I was wondering if it's posible to code a step verification of sorts from within the script. Or if that's imposible and i should just run the script from within the step event of an object which pretty much defeats the whole purpose.

Thanks in advance!

Code:
/// @description Get attack inputs
/// @param object
/// @param speed
/// @param direction
/// @param quantity
/// @param spacing
/// @param xpos
/// @param ypos


// capture input from the user and set up default values as required
var attack_part  = [];                                        if( argument_count >= 1) attack_object = argument[0];
var attack_object = "";                                        if( argument_count >= 2) attack_speed = argument[1];
var attack_speed = "";                                        if( argument_count >= 3) attack_direction = argument[2];
var attack_direction = true;                                if( argument_count >= 4) attack_quantity = argument[3];
var attack_quantity = "";                                    if( argument_count >= 5) attack_spacing = argument[4];
var attack_spacing = "";                                    if( argument_count >= 6) attack_ypos = argument[5];
var attack_xpos = "";                                        if( argument_count >= 7) attack_ypos = argument[6];
var attack_ypos = "";


// Spawn bullets in quantity
if (argument[3] > 0)
{
    while argument[3] > 0
    {
    
    inst = instance_create_layer(argument[5], argument[6], "Bullets", argument[0]);
    argument[3] -= argument[4];
    
        with inst
        {
            speed = argument [1];     
            if argument[2] = true
            {
                    direction = (point_direction(argument[0].x,argument[0].y,oArrowC.x,oArrowC.y));   
            }
            else if argument[2] = false
            {           
                argument[2] = argument[0].direction;     
            }
        }
    }
}
 

TheouAegis

Member
It has to run in a step event or a prestep event (which may as well just be in the Step event). You'll need a variable somewhere to keep track of which iteration you are on. There are no parallel processes in GM except the async events.
 
E

Erick is not unique

Guest
ok thanks, i ended up using the step event... haha
 
Top