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

SOLVED Pausing with statement

Ok, I'm sure this is easy, but I'm not sure how to go about it.

My code when it is the enemies turn.

GML:
    with(obj_enemy_par)
    {
        //do enemy movement
        event_user(0);
    }
This works perfectly. However every enemy moves at the same time in the same step. I need each
enemy to take turns doing their movement code. It doesn't matter what order they move in, why
it would be better if I could randomize the order a little so they don't get stale.

What I thought of doing is setting up a global variable "global.enemy_is_moving = true" and
when the event_user(0) is done setting it back to false so the loop can continue but I'm not sure
how to go about pausing a with statement without stopping the game.
 

chamaeleon

Member
Every (active/activated) instance will run all of its event every step. If you do not wish to have an instance do something a given step, make it conditional within the desired event. Have some control instance manage this condition by perhaps setting/resetting an instance variable (perhaps at the same time keeping track of which is the "currently selected" instance for reset purposes unless it seem cheap enough to figure out based on the set of existing instances every step), or have a variable containing the currently selected instance set in the begin step event of the control instance, so the instances can check it in the step or end step event. The possibilities are numerous.
 
Thanks for your replies :)

You could try using instance_find() with a variable to control which instance will perform next.
This is what I'm looking for, in the manual it uses a array but I can switch that out later for a ds list so I can remove enemies to achieve the random order. Thanks again. :)
 
Top