How do I make 1 minute always last 1 minute

Get help using Construct 2

Post » Mon Mar 10, 2014 1:55 pm

Hi, im still having some issues with time and performance, i have a game that lets you play for a minute or till you find all the hidden objects in a stage, score is calculated as (time)*100, scores are saved to a DB via Ajax.
The maximum possible score is 6000 and that means that you found 6 objects before 1 millisecond passed.
I've tried a few different implementations of the time and always end up having the same issue, users with really slow PCs have their time ticking slower that it is supposed to.
Im getting times like 5980, that are obviously impossible to achive saved to DB and most of those users when asked reported having really crappy PCs.
My current implementation of the timer is in the attached img.

Thanks in advance!
You do not have the required permissions to view the files attached to this post.
B
15
S
1
G
1
Posts: 15
Reputation: 1,051

Post » Mon Mar 10, 2014 1:58 pm

You should use delta time for this (dt) :
https://www.scirra.com/tutorials/67/del ... dependence

Start your timer at 60, every tick subtract dt from timer. It will always last 60 seconds.
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Mon Mar 10, 2014 2:12 pm

Thanks for the reply Joskin, i was told in a previous post that dt should not be used for timing as it's meant to be used only for movement.

avoid-timers-from-running-longer-than-expected_t92149

Now im confused hehehe.
B
15
S
1
G
1
Posts: 15
Reputation: 1,051

Post » Mon Mar 10, 2014 2:19 pm

Ah, weird, usually in development even for timer you will use delta time. I'm using dt for timers in my game and I have no problem.

We need another point of view ! :)
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Mon Mar 10, 2014 8:44 pm

In my old thread (avoid-timers-from-running-longer-than-expected_t92149) another user suggested dt is the way to go.

We could really use an official opinion about this issue.

Thanks!
B
15
S
1
G
1
Posts: 15
Reputation: 1,051

Post » Mon Mar 10, 2014 10:07 pm

Use dt, everybody use dt for time management.
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Mon Mar 10, 2014 10:27 pm

dt (deltatime) is the time (in second in c2) elapsed between the previous frame and the current.
So if you accumulate them you'll reach 1 in one second.
If you run at 60 fps (frame per second), the time between two frame is about 0.016s (1/60)
So after 60 frames, 1 second will have elapsed and you would have acumulated 60 * dt = 60 * 1/60 = 1.
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

Post » Mon Mar 10, 2014 10:30 pm

I would set a variable at the start of the loop to wallClock and then ever x seconds (or tenths of a second) compare the "now time" against this stored time. This way you should get a very accurate time.
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,882

Post » Mon Mar 10, 2014 11:22 pm

not really sure if the problem is about dt or using time, time should have the same accuracy as dt, No?

maybe some slight difference in your logic, ... or they are cheating somehow..
ImageImage
B
70
S
21
G
7
Posts: 827
Reputation: 10,052

Post » Tue Mar 11, 2014 1:31 am

That's how I would implement your system
hiddenObjectClock.capx

dt and time have the same accuracy, as time is internally computed by adding dt to it each frame.
Last edited by Yann on Sun Sep 14, 2014 7:03 pm, edited 1 time in total.
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

Next

Return to How do I....?

Who is online

Users browsing this forum: Artcadev, brunopalermo, Exabot [Bot] and 23 guests