# How do I add a 'life timer' to reward player for not dying?

Get help using Construct 2

### » Tue Jan 17, 2017 1:52 pm

I'd like to reward the player with a single power-up if they can go X minutes without dying.

I've looked at game time but that won't let me. Timer behavior doesn't seem to work either.

I also thought about adding dt to a GV. Then if that GV is equal to X minutes (secs) reward the player and reset the GV.

Would this work?
B
38
S
18
G
19
Posts: 664
Reputation: 14,112

### » Tue Jan 17, 2017 6:12 pm

Should do, yeah. Or 'wallclocktime' might help.
The LEVEL GENERATOR TOOLKIT

24 functions dedicated to producing randomly generated terrain for all kinds of games.
B
25
S
7
Posts: 254
Reputation: 2,332

### » Tue Jan 17, 2017 6:20 pm

Using your GV:

Initially (or at Start of Layout) set GV to [X minutes] * 60.

Every Tick | GV-dt

If GV <= 0 | [Reward the Life Timer]

I don't know what you mean by life timer but I'm assuming it's a timer of your player's life that starts at a certain amount and decreases?

If so, you need more variables. Say:

LT [Life Timer] = [Your desired life]
IsRewarded = 0

You would then add:

If GV <= 0 | [Reward the Life Timer] Set IsRewarded to 1

If IsRewarded == 1 | LT-dt
If LT <= 0 | Set LT to 0 (So your life timer won't go negative.)
B
33
S
12
G
27
Posts: 761
Reputation: 17,286

### » Tue Jan 17, 2017 7:39 pm

No. Nothing that complex. It's just to see if the player can play (say 10 mins) without dying, they get a reward.

After i fix this 1 bug that popped up, gonna try it out.

Thanks for the replies.
B
38
S
18
G
19
Posts: 664
Reputation: 14,112

Return to How do I....?

### Who is online

Users browsing this forum: ShayLei and 5 guests