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

Big Steve

Member
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
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
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. :)
 
Top