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

How do I add Time to my Timer Countdown?

N

Neymar

Guest
I have a Timer in my game that counts from 60 to 0. But I have an object in my game that has to add 10 seconds to the timer and make it possible to win the map. But i always changed the room_speed id i collect that item. That made the game work slower, but the 10 secs were add to the timer.

How to solve that issue?

Please help me to solve it without changing the room_roomspeed.
 

chamaeleon

Member
I have a Timer in my game that counts from 60 to 0. But I have an object in my game that has to add 10 seconds to the timer and make it possible to win the map. But i always changed the room_speed id i collect that item. That made the game work slower, but the 10 secs were add to the timer.

How to solve that issue?

Please help me to solve it without changing the room_roomspeed.
Please post code and context for the code so people can help you better. If you have something that goes from 60 to 0 right now, what is the problem with adding 10 (or room_speed*10) to whatever holds the value counting down?
 

FoxyOfJungle

Kazan Games
I do not recommend changing the game speed, what you can do is create a global speed variable, and modify it as you wish, and use it within an object that will depend on the variable.
 

sinigrimi

Member
creation code:
timer =0;

step event:
if alarm[0]<=0{
alarm [0] = room_speed // it will work every second
}
if (timer >= 60){
your events;}
if (place_meeting(x,y,object){//or any other your event
timer -=10;
}

in alarm[0]:
timer += 1;
 
Last edited:

sinigrimi

Member
That alarm will never countdown and fire because you are setting it to room_speed every step.
then why does this work for me? (room_speed also equals 60 for me)
i use this code, and it video proof

Code:
if (canattack == true  and distance_to_object(oPlayer) <=400){
        canattack = false;
        alarm [1] = room_speed;
 
    }
\

UPD: I created another object and it doesn’t work with alarm until I write "if alarm <= 0 {}" now I'm confused why it works for me, maybe because it somehow manages to reset, I don’t understand :D
Code:
if alarm [1]<=0
alarm [1] = room_speed;
 
Last edited:

rIKmAN

Member
then why does this work for me? (room_speed also equals 60 for me)
i use this code, and it video proof

Code:
if (canattack == true  and distance_to_object(oPlayer) <=400){
        canattack = false;
        alarm [1] = room_speed;
 
    }
\

UPD: I created another object and it doesn’t work with alarm until I write "if alarm <= 0 {}" now I'm confused why it works for me, maybe because it somehow manages to reset, I don’t understand :D
Code:
if alarm [1]<=0
alarm [1] = room_speed;
In the code above you have it enclosed in if checks - which means it only runs when the if is true.
In the above cases that will be when canattack is true and the distance to oPlayer is <= 400 (for the first one), or when the alarm has fired and is <= 0 (in your updated edit).

In your original code that I replied you have it in a Step Event with no checks so it runs every step no matter what. This means that it will never count down as it will be set to 60 every step.

Be aware that the alarm also won't count down and will be getting reset every step when canattack is true and the distance is less than 400 as well, because every time the if check evaluates to true the code within will be run - setting the alarm to room_speed.
 
Top