Skip to content

Commit 01f9f43

Browse files
committed
Game loop timing: More tests suggest 144 hz monitors like 0.33 for 30 FPS.
1 parent b214aad commit 01f9f43

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

script/core/global.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,20 @@ const ua = navigator.userAgent;
1111
const FPS = 30;
1212
const FRAMERATE = 1000 / FPS;
1313

14-
// skip frame(s) as needed, prevent the game from running too fast.
15-
const FRAME_MIN_TIME = (1000 / 60) * (60 / FPS) - (1000 / 60) * 0.5;
14+
/**
15+
* Skip frame(s) as needed, prevent the game from running too fast.
16+
*
17+
* Note: 144 hz monitors (maybe on Windows?) may need 0.33 or less,
18+
* or else the loop may run at 35+ FPS. This may be a 144 hz
19+
* monitor thing, not necessarily tied to Windows. TBD.
20+
*
21+
* It may be this value needs to be made dynamic, starting at 0.5
22+
* and trickling down to 0.33 or so if the frame rate is > 30FPS.
23+
*
24+
*/
25+
const frameOffset = parseFloat(searchParams.get('frameOffset')) || 0.33;
26+
27+
const FRAME_MIN_TIME = (1000 / 60) * (60 / FPS) - (1000 / 60) * frameOffset;
1628

1729
/**
1830
*

0 commit comments

Comments
 (0)