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
}
});
curl -fsSL https://bun.sh/install | bash
- start: "bun run index.ts",
- bundle: "bun run bundler/bundler.ts",
- list: "bun run samples/list-scripts.tsx",
- example: "cd example && bun start && cd ..",
- fileSample: "bun run samples/file.tsx && cat samples/data/test.json",
- httpSample: "bun run samples/server.tsx"