How to make a timer for my game

I have a game where you have to try to survive for as long as you can but I don’t know how to make a timer to show how long you survived

Explain to me how exactly you want to “show how long you survived” and I can try to help.

Like i want to make a timer that you can see so that when you die its says something like you got a time of 10 seconds. muphins

I also need to know exactly what happens when you die, so you can implement this correctly. In any case, this is what I would do:

  1. Add a block anywhere outside of your map, and go to its behaviors.
  2. Add two labels (they are underneath GUI):
    -the first label should be text, such as:
    “You got a time of:”
    -the second label should be a 0
    -edit the color and font of the labels to your liking.
  3. Pull down the top of the behavior window so you can see the game and the labels clearly.
  4. Click and drag these labels where you so desire.

Then just follow the rest of these steps, because they are rather difficult to explain clearly with words:

help

*Just a few notes pertaining to those behaviors:
-Make the timer “10” and toggle the “Repeat forever” box
-Make the switch on initially. The once trigger is there to make sure it does switch on, although that connection isn’t really necessary.

Your job is to figure out how you will send the “dead” message. Basically, the “dead” message stops the timer, in addition to making the label actually visible.

You also need to figure out when exactly you need to start this timer. That “Game start” message starts the timer. You don’t need the keyboard trigger, I just had that there for testing purposes.

I’m not entirely sure if the label will appear or not. If it doesn’t, you can try to improvise or I can try to help again.

Any questions, feel free to ask. Hope I was able to help :slight_smile:

can you check out my game i did everything (I think) but the message appears but doesn’t count

And thanks for you help so far

@muphins

Yeah, I’ll take a look. Just post the link.

http://www.flowlab.io/game/play/74741

@muphins

You have two labels that are supposed to feature time…so I’ll just go with the labels under the “block” object. And just for the record, you didn’t have to bundle it up :slight_smile:

First thing’s first, delete the blocks on the sides. Reason being, multiple labels are spawning, and I’m not too sure what that would do to the game. It would probably slow it down, so I’d suggest getting rid of them. Keep at least ONE, and you can replace the walls with the green blocks on the floor.

I notice the game starts automatically. I thought you would have to press a button to start the game. If that is the case, get rid of the “Game Start” Mailbox, and replace the connection, with the “once” trigger. “Once” and “always” triggers will automatically fire upon game launch, so make sure to use those when you see fit.

Considering the game never pauses after you die, I’ll just assume that you want the timer to always be visible, correct?

Yes and we made a step but i found a problem it doesn’t say you got a time of it just says 0 when you play the game even though its says you got a time of in the editor and the timer only goes to 1 @muphins

@grazer can you help

If you want the timer to be visible, than you can get rid of a lot of the behaviors. And I also fixed the timer.

help

OMG THANK YOU SO MUCH @Muphins Thank you Thank you Thank you

Another question @muphins do you think i would be able to make a alert appear when you collide with a spike. and the alert says what my time is and when you click the alert it restarts the game. If so how

The alert cannot show your time, because there is no input plug. However, you can make a filter, and a bunch of alerts for “You survived over 1 minute.” “2 minutes.” “3, 4, 5, etc.” if you wanted.