import { Engine, EngineOptions } from '@rpg/engine';
import { Game } from './Game';
import { BootScene } from './scenes/BootScene';
/** Целочисленный масштаб под текущее окно (pixel-perfect). */
function pickScale(vw: number, vh: number): number {
return Math.max(1, Math.floor(Math.min(window.innerWidth / vw, window.innerHeight / vh)));
}
async function main(): Promise<void> {
const container = document.getElementById('game')!;
const options: EngineOptions = {
virtualWidth: Game.VIRTUAL_W,
virtualHeight: Game.VIRTUAL_H,
scale: pickScale(Game.VIRTUAL_W, Game.VIRTUAL_H),
background: 0x0b0b12,
fixedFps: 60,
parent: container
};
const engine = new Engine(options);
await engine.init();
engine.input.bindActions({
advance: ['Space', 'Enter'],
menu: ['Escape']
});
const game = new Game(engine);
await engine.scenes.push(new BootScene(game));
await engine.start();
}
void main();