"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GameEngine = void 0;
class GameEngine {
    game;
    intervalHandle = null;
    lastTick = 0;
    TICK_INTERVAL_MS = 16;
    constructor(game) {
        this.game = game;
    }
    init(width, height) {
        this.game.init(width, height);
    }
    start() {
        if (this.intervalHandle)
            return;
        this.lastTick = performance.now();
        this.intervalHandle = setInterval(() => {
            const now = performance.now();
            const delta = now - this.lastTick;
            this.lastTick = now;
            if (!this.game.isPaused() && !this.game.isGameOver()) {
                this.game.tick(delta);
            }
        }, this.TICK_INTERVAL_MS);
    }
    stop() {
        if (this.intervalHandle) {
            clearInterval(this.intervalHandle);
            this.intervalHandle = null;
        }
    }
    handleInput(key) {
        this.game.handleInput(key);
    }
    getState() {
        return this.game.getState();
    }
    resize(width, height) {
        this.game.resize(width, height);
    }
    pause() { this.game.pause(); }
    resume() { this.game.resume(); }
    reset() { this.game.reset(); }
    get isPaused() { return this.game.isPaused(); }
    get isGameOver() { return this.game.isGameOver(); }
    get currentGame() { return this.game; }
}
exports.GameEngine = GameEngine;
//# sourceMappingURL=game-engine.js.map