• 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 switch inside another switch statement - is my code placed in the right context?

jobjorgos

Member
I have the following code in obj_canon
but why it always becomes spr_canon_up? it should have a RANDOM direction

Create event:
GML:
shoot_direction= -1
alarm[0]=45;

Alarm[0] event:
GML:
switch shoot_direction{
    case -1:
        chance = irandom(3)
        switch chance{
            case 0: sprite_index=spr_canon_up break; 
            case 1: sprite_index=spr_canon_down break; 
            case 2: sprite_index=spr_canon_left break; 
            case 3: sprite_index=spr_canon_right break; 
        }
    case 0: sprite_index=spr_canon_up break; 
    case 1: sprite_index=spr_canon_down break; 
    case 2: sprite_index=spr_canon_left break; 
    case 3: sprite_index=spr_canon_right break; 
}
 
Top