Motor loop is a typescript library that runs a game loop continuously.
Notably, it adapts to frameRate to ensure your game always runs smoothly when the monitor refresh rate goes above or below 60hz.
It’s also used to schedule updates.
const motor = new Motor();
// This will cause your refresh method to be called continously at the frameRate specified
motor.loop({
refresh: (updatePayload) {
// execute continously
doSomethingWith(updatePayload.data);
}
}, data, frameRate);
// You can also schedule an update. The update will only be executed one time
motor.scheduleUpdate({
refresh: (updatePayload) {
// update something
}
});
https://bun.sh/
curl -fsSL https://bun.sh/install | bash
https://jacklehamster.github.io/motor-loop/example/