GML How to create a timer using delta time?

B

Big_Macca_101

Guest
I'm working on a game and I decided to use delta time and set the game speed to 240 (Yes it's overkill) but I've noticed when using the standard alarms and setting it to be the game speed (So it should execute after one second) it takes much longer using the UWP export.

It works perfectly on all desktop exports and android so was curious if anyone is able to point me in the right direction to build a timer system similar to alarms using delta time?

This is how I'm calculating my delta btw...

Code:
delta = delta_time / 1000000;
 

FrostyCat

Redemption Seeker
It's the same principle as manual fake alarms, just with different units.

Create:
Code:
delta_alarm = 5000000;
Step:
Code:
if (delta_alarm > 0) {
  delta_alarm -= delta_time;
  if (delta_alarm <= 0) {
    /* Action here */
  }
}
 
B

Big_Macca_101

Guest
It's the same principle as manual fake alarms, just with different units.

Create:
Code:
delta_alarm = 5000000;
Step:
Code:
if (delta_alarm > 0) {
  delta_alarm -= delta_time;
  if (delta_alarm <= 0) {
    /* Action here */
  }
}
Yeah I knew that way but was more after a way to set the timer for a few seconds rather than a magic number, probably should have stated that in the post :-/
 

FrostyCat

Redemption Seeker
Yeah I knew that way but was more after a way to set the timer for a few seconds rather than a magic number, probably should have stated that in the post :-/
Same idea. n seconds is equivalent to n*1000000 microseconds.

My example shows 5 seconds. If you want another duration, multiply it out yourself.
 
B

Big_Macca_101

Guest
Same idea. n seconds is equivalent to n*1000000 microseconds.

My example shows 5 seconds. If you want another duration, multiply it out yourself.
Oh my god I'm an idiot, I didn't even notice it, already added and working, thanks!
 
Top