/** * GameLoop.ts — Sprint 6 * * A simple deterministic game loop using setInterval for portability * across Node.js and browser environments. Exposes start/stop/pause/resume * and calls the provided `onUpdate(deltaMs)` callback each tick. * * Design choices: * - Uses setInterval rather than requestAnimationFrame so tests can advance * time without requiring a browser runtime. * - `tickIntervalMs` defaults to 16ms (≈60 fps) but is overridable. * - `pause()` keeps the interval alive but skips the onUpdate call, * preserving the timing baseline so resume is seamless. * - `frame` is incremented every time onUpdate fires (not every tick). */ export interface GameLoopOptions { /** Called each tick with deltaMs since last tick (paused ticks are skipped). */ onUpdate: (deltaMs: number) => void | Promise; /** * Interval between ticks in ms. * @default 16 (approx. 60 fps) */ tickIntervalMs?: number; /** * Alias for tickIntervalMs, derived from fps. * If provided, takes precedence over tickIntervalMs. */ targetFps?: number; } export declare class GameLoop { private _isRunning; private _isPaused; private _frame; private _handle; private _lastTime; private readonly onUpdate; private readonly intervalMs; constructor(options: GameLoopOptions); /** Whether the loop is currently running (not stopped). */ get isRunning(): boolean; /** Whether the loop is paused (running but not ticking). */ get isPaused(): boolean; /** Number of update calls since start() (skips paused frames). */ get frame(): number; /** * Start the game loop. * If already running, this is a no-op. */ start(): void; /** * Stop the game loop permanently. * Resets frame counter and running state. */ stop(): void; /** * Pause the loop. `isRunning` stays true but `onUpdate` is not called. * The interval continues so resuming has minimal lag. */ pause(): void; /** * Resume from a paused state. Resets the last-time baseline so the first * resumed tick doesn't produce an artificially large delta. */ resume(): void; private _tick; } //# sourceMappingURL=GameLoop.d.ts.map