/** * VillSim - Phaser Web Frontend * Main entry point */ import BootScene from './scenes/BootScene.js'; import GameScene from './scenes/GameScene.js'; // Calculate game dimensions based on container function getGameDimensions() { const container = document.getElementById('game-container'); if (!container) { return { width: 800, height: 600 }; } const rect = container.getBoundingClientRect(); return { width: Math.floor(rect.width), height: Math.floor(rect.height), }; } // Phaser game configuration const { width, height } = getGameDimensions(); const config = { type: Phaser.AUTO, parent: 'game-container', width: width, height: height, backgroundColor: '#151921', scene: [BootScene, GameScene], scale: { mode: Phaser.Scale.RESIZE, autoCenter: Phaser.Scale.CENTER_BOTH, }, render: { antialias: true, pixelArt: false, roundPixels: true, }, physics: { default: 'arcade', arcade: { gravity: { y: 0 }, debug: false, }, }, dom: { createContainer: true, }, }; // Initialize game when DOM is ready document.addEventListener('DOMContentLoaded', () => { console.log('VillSim Web Frontend starting...'); // Create Phaser game const game = new Phaser.Game(config); // Handle window resize window.addEventListener('resize', () => { const { width, height } = getGameDimensions(); game.scale.resize(width, height); }); // Store game reference globally for debugging window.villsimGame = game; }); // Export for debugging export { config };