Timing of Events

Just started using Construct 2? Post your questions here

Post » Fri May 19, 2017 2:15 pm

Hey, guys.

Had a question on timing of events in game.

I'm doing variable timers so far and they seem to work great, even for syncing animation frames to sound. I tested on my mobile android phone and saw no difference vs. pc.

Doing another global variable "clock" to control timing of events/transition effects.

However, in debug view, under "system", I also noticed "wall clock", "time (system time)", and "time scale". If you let these run for a while (don't think it would be a major issue in what I'm doing, but still...), there are vast differences between all 4, including my variable clock.

I also noticed some people add dt to their timer variables. I've used dt before to account for differences in system "times" before for many things, but here?

I did some Goggling on "scirra wall clock", but I'm still unclear on the differences and the pros and cons of each approach and pitfalls if any.

Would making a global variable clock say adding 0.01 every 0.01 seconds (system-> every 0.01 seconds, add 0.01 to global variable) pretty much make it full proof vs. any system?
Posts: 259
Reputation: 12,922

Post » Sun May 21, 2017 2:47 am

Wall Clock time grabs your machine's time relative to the startup of a project, and system time does that in its own environment * by time scale (or dt/delta time.)
Since Variable timers reference the system time, they are essentially the same thing

If you were designing something of a multiplayer game, wall clock time would be the better option. In any other situation, using system time would definitely be the way to go. I try to avoid Wall Clock time if I can. It really makes your project more streamlined and will probably save you a lot of headaches down the road of development.
Posts: 17
Reputation: 1,401

Post » Sun May 21, 2017 11:19 am

Implementing a system clock is the way to go, wall clock can be easy abused because it uses the user time, which he can easy change to get some kind of advantage.

I had a simple clock on my game implement with 3 variable, 1 for seconds, 1 for minutes and 1 for hours, every 1 second when the game should be running I increment the second variable by 1, when it gets to 60 I reset it to 0, and add 1 to minutes, when minutes get to 60 I reset it to 0 and add 1 to hours. You can make a simple clock like that, and If you want to continue where it stoped after the game is closed, you can keep the variable values in a json file and load that on game start.
Like my work? Fallow me on social media, and see my games on the arcade.
Posts: 298
Reputation: 5,367

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 3 guests