// --- Global Error Handler --- class ErrorHandler { static init() { window.onerror = (message, source, lineno, colno, error) => { ErrorHandler.showError(message, source, lineno, colno, error); return false; }; window.addEventListener('unhandledrejection', (event) => { ErrorHandler.showError('Unhandled Promise Rejection', '', 0, 0, event.reason); }); console.log('🛡️ Global Error Handler Initialized'); } static showError(message, source, lineno, colno, error) { console.error('🔥 CRITICAL ERROR:', message); if (document.getElementById('error-overlay')) return; const div = document.createElement('div'); div.id = 'error-overlay'; div.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(20,0,0,0.95);color:#ffaaaa;z-index:999999;display:flex;flex-direction:column;justify-content:center;align-items:center;font-family:monospace;padding:20px;text-align:center;'; const stack = error && error.stack ? error.stack : ''; div.innerHTML = `

☠️ OOPS! GAME CRASHED ☠️

${message}
${source}:${lineno}:${colno}

${stack}
`; document.body.appendChild(div); } } ErrorHandler.init(); // Phaser Game Configuration const config = { type: Phaser.CANVAS, // Canvas renderer za pixel-perfect ostrino width: 1024, // Larger viewport for better view height: 768, // 4:3 aspect ratio parent: 'game-container', backgroundColor: '#1a1a2e', pixelArt: true, antialias: false, roundPixels: true, render: { pixelArt: true, antialias: false, roundPixels: true, transparent: false, clearBeforeRender: true, powerPreference: 'high-performance', premultipliedAlpha: true, // Fix transparency failIfMajorPerformanceCaveat: false, // Eksplicitna NEAREST_NEIGHBOR filtracija mipmapFilter: 'NEAREST', batchSize: 4096 }, physics: { default: 'arcade', arcade: { gravity: { y: 0 }, debug: false } }, scene: [BootScene, PreloadScene, StoryScene, GameScene, UIScene], scale: { mode: Phaser.Scale.FIT, autoCenter: Phaser.Scale.CENTER_BOTH }, input: { gamepad: true }, fps: { target: 60, forceSetTimeOut: false } }; // Initialize game const game = new Phaser.Game(config); // Global game state window.gameState = { currentScene: null, debugMode: true }; // God mode disabled by default (can be enabled via console) window.godMode = false; console.log('💀 Mrtva Dolina initialized!');