# Time math : Any tips?

0 favourites
• 10 posts
From the Asset Store
Time rewind like in "Braid". Choose objects that will be affected by time rewind
• Part of my scoring is based on the time it takes to do a level. I want to be able to capture the time they started, the time they ended and then find the difference between the two.

Is this possible in native Construct or are there any libraries or plugins I can use for this purpose?

I could increment a counter every "tick" I guess to keep up with that, but didn't want to add that per tick workload to the game if I didn't need to.

The score requires you to complete a challenge in a single sitting. If you switch apps, you "fault" and no score is recorded though you can come back and finish, you just won't be scored.

Any help would be most appreciated. I've set aside my Construct project for too long and want to get this market (tying up these loose ends) ASAP! :)

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• Sorry, in a hurry, but here is a timer tutorial:

https://www.scirra.com/tutorials/173/time-counter

and if it didn't format here is a thread I used for my timer in Orbital Bomb-Bounder:

http://www.scirra.com/forum/time-remaining-string-Formatting_topic48212.html

• I think having a counter increase every tick isn't really taxing at all, but however, you may be able to do it this way:

Start of Layout

Set a value ("StartTime") to the expression wallclock

End of Layout

Set a value ("EndTime") to wallclock

And then to calculate the time, you simply do Endtime-StartTime.

If not wallclock, there's probably another time expression :P

• Best tip I could give is learn what %, or modulo does.

• var start_time = 0

var pause_time = 0

var pause_total = 0

On Level Start

start_time = time

On Pause

pause_time = time

On Unpause

pause_total = time - pause_time

On End Level

(time - start_time) - pause_time

• Excellent. Thanks!

• Best tip I could give is learn what %, or modulo does.

Already know what that does... not sure that answer was much help. Thanks to the others however who pointed me to values to actually get the time.

• Sounds easy enough. My suggestion:

1) Set a global variable to 0 at the start of the level

2) On every tick, add dt to the variable

The global variable will contain the number of seconds that have passed since your event 2 became active.

Check out this manual entry

• add a variable, int(), timecheck.

When you want it to record the first moment: set value timecheck = wallclocktime

when your done, set the value again: timecheck = wallclocktime - timecheck.

Voila, time difference between begin and end time.

• 10 posts