Created
June 25, 2026 08:01
-
-
Save Shilo/af19dabd4d438ae8f40516b83cea7b3d to your computer and use it in GitHub Desktop.
Web game/app speed modifier. [Use responsibility, dont cheat multiplayer games]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| window.__setGameSpeed = (speedMultiplier) => { | |
| window.__requestAnimationFrame ??= window.requestAnimationFrame.bind(window); | |
| const startTime = window.performance.now(); | |
| window.requestAnimationFrame = function (callback) { | |
| return window.__requestAnimationFrame(function (timestamp) { | |
| const elapsedTime = timestamp - startTime; | |
| const fakeTimestamp = startTime + elapsedTime * speedMultiplier; | |
| callback(fakeTimestamp); | |
| }); | |
| }; | |
| console.log(`Game speed set to ${speedMultiplier}x.`); | |
| }; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: