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

Legacy GM (SOLVED) Why wont this work

J

JDSTIGER

Guest
Having some problems with the alarms..:

Code:
//return to menu in 3 seconds when game is over
if (game_over) {
    
   alarm[4] = 120;
    
}
But the code right before it works:
Code:
 if (!game_over) {
        alarm[2] = 90;
    }
}
I could use any other code in place of the alarm & it works fine..:
Code:
if (game_over) {
    
 room_goto (rm_menu)
    
}
 
S

Silver_Mantis

Guest
You should use room_speed for your counter, it's much much easier.

I'll give you an example.

Code:
// Set alarm for 3 seconds.
alarm[0] = room_speed * 2;
You also want to use the Else Statement, instead of using two If Statements.
Like this:

Code:
if (!game_over)
{
alarm[2] = room_speed * 1;
}
else
{
alarm[4] = room_speed * 2;
}
Try that! :D
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
You do not check whether alarm was not set yet, so may very well be re-setting it to 120 frames every frame (meaning that it won't expire for as long as game_over == true).
 
C

chaotic

Guest
Your if statement keeps checking to true so it resets the alarm to 120 seconds every gamestep

Code:
//return to menu in 3 seconds when game is over
if (statement == true) {
    
   alarm[0] = 120;
   statement = false; // Gotta set to false otherwise it will keep checking true
                      // meaning it keeps resetting alarm
}
 
J

JDSTIGER

Guest
What's up with the clickbait titles? Tell us at least something useful in your title. My god youtube is really corrupting the internet ): ^
Well, it wasn't misleading right? Also, ' My God, YouTube... ' ** ;)
Your if statement keeps checking to true so it resets the alarm to 120 seconds every gamestep

Code:
//return to menu in 3 seconds when game is over
if (statement == true) {
   
   alarm[0] = 120;
   statement = false; // Gotta set to false otherwise it will keep checking true
                      // meaning it keeps resetting alarm
}
This worked thank you!! & thanks to all who replied :)
 
J

JDSTIGER

Guest
You should use room_speed for your counter, it's much much easier.

I'll give you an example.

Code:
// Set alarm for 3 seconds.
alarm[0] = room_speed * 2;
You also want to use the Else Statement, instead of using two If Statements.
Like this:

Code:
if (!game_over)
{
alarm[2] = room_speed * 1;
}
else
{
alarm[4] = room_speed * 2;
}
Try that! :D
****Actually**** This worked better making it an Else statement, thank you!
 
Top