popravek zombijo
This commit is contained in:
40
src/game.js
40
src/game.js
@@ -1,3 +1,43 @@
|
||||
// --- 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 = `
|
||||
<h1 style="color:#ff4444;margin-bottom:20px;">☠️ OOPS! GAME CRASHED ☠️</h1>
|
||||
<div style="background:rgba(0,0,0,0.5);padding:15px;border:1px solid #ff4444;max-width:800px;max-height:300px;overflow:auto;text-align:left;margin-bottom:20px;white-space:pre-wrap;">
|
||||
<strong>${message}</strong><br>
|
||||
<small>${source}:${lineno}:${colno}</small><br><br>
|
||||
${stack}
|
||||
</div>
|
||||
<div>
|
||||
<button onclick="window.location.reload()" style="padding:15px 30px;font-size:18px;font-weight:bold;background:#44aa44;color:white;border:none;cursor:pointer;border-radius:5px;margin-right:10px;">🔄 RELOAD GAME</button>
|
||||
<button onclick="document.getElementById('error-overlay').remove()" style="padding:15px 30px;font-size:14px;background:#666;color:white;border:none;cursor:pointer;border-radius:5px;">IGNORE</button>
|
||||
</div>
|
||||
`;
|
||||
document.body.appendChild(div);
|
||||
}
|
||||
}
|
||||
ErrorHandler.init();
|
||||
|
||||
// Phaser Game Configuration
|
||||
const config = {
|
||||
type: Phaser.CANVAS, // Canvas renderer za pixel-perfect ostrino
|
||||
|
||||
Reference in New Issue
Block a user