UNPKG

@fuwu-yuan/bgew

Version:

Baguette Game Engine Web is a french 2D Web game engine

24 lines (23 loc) 909 B
export declare class Gameloop { private activeLoops; private getLoopId; private getNano; private s2nano; private nano2s; private ms2nano; /** * Create a game loop that will attempt to update at some target `tickLengthMs`. * * `tickLengthMs` defaults to 30fps (~33.33ms). * * Internally, the `gameLoop` function created has two mechanisms to update itself. * One for coarse-grained updates (with `setTimeout`) and one for fine-grained * updates (with `setImmediate`). * * On each tick, we set a target time for the next tick. We attempt to use the coarse- * grained "long wait" to get most of the way to our target tick time, then use the * fine-grained wait to wait the remaining time. */ setGameLoop: (update: (delta: number) => void, tickLengthMs?: number) => number; clearGameLoop: (loopId: number) => void; }