How to detect slowed down time

How to detect slowed down time
0

so i have this game i made. its currently on google play and one of my players told me that they can slow down the game time, making the obstacles stop coming and basically play without any obstacles. makes sense since im making obstacles every 3 and 5 seconds so is there a way to prevent this? or maybe to detect it?

how do they stop the game time? perhaps switch to a frame based approach?

1 Like

they dont stop it they just slow it down. oh thats a great idea since i nearly never used update() couldnt think of it. thanks ill try.

frame-based is one approach, for some games might work. if you still want to keep the time-based approach, i would recommend clamping the difference between timestamps to a certain interval (e.g. 0…1000 miliseconds, to also account for negative differences - device time moved backwards), like so:

const now: number = new Date().getTime();
const diff: number = clamp(now - lastTimerTimestamp, 0, 1000);

if (diff > somevalue) {
  // do you generation code
}

lastTimerTimestamp = now;

you’ll have to implement clamp, though.

depending on your game, you can even go for a more aggressive clamping of the upper bound, say instead of 1000ms to a couple of multiples of 1000/FPS ms (if your game doesn’t have constant fps drops).

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.