time limit

how to put time limit on a game?..

Logic: Start a timer at the beginning of the scene (or when the countdown starts), and check for the timer greater than the time limit to launch the actions related (mission failed, no time bonus, etc.) :slight_smile:

Events:


Here I start the timer at the beginning of the scene, so reseting the timer is not needed, but if you start the timer with other conditions (for example, reach a zone), you should reset the timer to ensure it starts at zero (maybe it was counting from the beginning) :stuck_out_tongue:
And here, the time limit is 5 seconds, of course you can use variables and any numeric expression in general :slight_smile:

lizard, by doing this, we can put a limit or something in the game, how can we show this countdown as a countdown in the screen of the game?
i don’t know if we can assosiate this “countdown timer” directly to a “text object” so i create a global variable “countdown1” with the value 60 (beacuse a want 60seconds to clear the stage and i the player can’t do it in this time, restart the game) and i make the action "Do = "Time: " + GlobalVariableString(countdown1) to the text “my text object”. And it shows in the corner Time: 60, but it doesn’t make the countdowns second by second, (60-59-58-57…0) Can you help me with this?
I suppose i have to associate the variable “countdown1” with a time value… but i don’t know how… :cry:

i’m trying:
Do -1*TimeDelta() to variable countdown1
But is not working… it’s in 60 yet, it doesn’t make a countdown… What i’m making wrong?

That should work, maybe you are not updating the variable and text every frame… It works for me:

Still don’t work for me…
Sorry lizard, how i upload the the variable and text every frame?
I don’t understand this, i though it was automatically done every second :confused: :confused:

In my last image, the variable and text are updated every frame because the second event runs every frame (it has no conditions) :wink:
You said you update the variable subtracting TimeDelta() and this is ok, but maybe this event has conditions or is a sub-event of other event with conditions, and doesn’t run every frame.

If you have problems to catch the error, you could attach the project here (.gdg file + resources in a .zip) (while writing a reply, under the writing area, there is a “Upload attachment” tab) :slight_smile:

Wow… Can’t believe how silly i am… Now it’s working… I dind’t realize about the condition… of course that is… I use to program php and javascript like 4-5 years ago… I’m becoming silly beacuse i don’t program for all this time… :cry: :cry:

Thanks for your help Lizard-13 one less problem, still some :cry:

Don’t worry :slight_smile: