43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
import Phaser from './vendor/phaser.js';
|
|
import { config } from './config/Config.js';
|
|
import { ConfigLoader } from './config/ConfigLoader.js';
|
|
import { createGameConfig } from './config/GameConfig.js';
|
|
import { MenuScene } from './scenes/MenuScene.js';
|
|
import { GameScene } from './scenes/GameScene.js';
|
|
|
|
/**
|
|
* Orbit — entry point.
|
|
*
|
|
* 1. Load config JSON (data/manifest.json → data/*.json)
|
|
* 2. Initialize the global config singleton
|
|
* 3. Build the Phaser game config and attach the scenes
|
|
* 4. Boot
|
|
*/
|
|
async function boot() {
|
|
const data = await ConfigLoader.load();
|
|
config.init(data);
|
|
|
|
const gameConfig = createGameConfig();
|
|
gameConfig.scene = [MenuScene, GameScene];
|
|
|
|
const game = new Phaser.Game(gameConfig);
|
|
|
|
// Handy for console debugging.
|
|
window.game = game;
|
|
window.config = config;
|
|
console.info(
|
|
`%c${config.get('game.name', 'Orbit')} %c${config.get('game.version', '')}`,
|
|
'font-weight:bold;font-size:14px',
|
|
'color:#8fa0c9',
|
|
);
|
|
}
|
|
|
|
boot().catch((err) => {
|
|
console.error(err);
|
|
const pre = document.createElement('pre');
|
|
pre.style.cssText =
|
|
'color:#ff9b9b;font:14px/1.6 monospace;padding:2rem;white-space:pre-wrap;margin:0';
|
|
pre.textContent = `Failed to start Orbit:\n${(err && (err.stack || err.message)) || err}`;
|
|
document.body.appendChild(pre);
|
|
});
|