1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Changing rooms after a room has been switched to a certain amount of times

Discussion in 'Programming' started by Big Steve, Feb 12, 2020.

  1. Big Steve

    Big Steve Member

    Joined:
    Feb 10, 2020
    Posts:
    3
    in a room after it has been switched to 3 times i want it to change to a game over screen which in in a separate room, so i need a way to make it switch to a game over room after a life loss room has been switched to 3 times

    GML if possible, thank you in advance
     
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    7,144
    Use a global variable. From the main menu when the game is started, set it to 3, then in the game end event of a controller object check it, and if it's greater than 0, subtrract one and go to the next game room, and if it's not greater than 0 then go to the game over room... So...
    Code:
    //OBJECT IN MENU ROOM BEFORE GAME STARTS
    global.game_count = 3;
    
    // ROOM END EVENT (or whatever) OF CONTROLLER IN GAME ROOM
    if global.game_count > 0
    {
    global.game_count -=1;
    room_goto(rm_game);
    }
    else room_gotot(rm_GameOver);

    Something like that. :)
     

Share This Page