Files
novafarma/src/game.js
David Kotnik 8631958ade 📚 MASTER DOCUMENTATION UPDATE - Complete Game Bible & Production Guides
## New Master Documents (16 files):

### Game Content:
- GAME_BIBLE_FINAL_2026.md (5703 lines - Ultimate master bible)
- GAME_BIBLE_2026_ULTIMATE.md (All specs + systems)
- GAME_BIBLE_2026_MASTER.md (Overview)
- BIOMES_ALL_20_COMPLETE.md (All 20 biomes detailed)
- STORY_COMPLETE_MASTER.md (Complete story + dialogues)

### Production & Phases:
- PRODUCTION_10_FAZAS_FINAL.md (10-phase release roadmap)
- DEMO_FAZA1_FAZA2_COMPLETE_GUIDE.md (Assets, NPCs, progression)
- DEMO_FAZA1_FAZA2_FINAL.md (Asset counts breakdown)

### Game Systems:
- DRUG_EMPIRE_SYSTEM_COMPLETE.md (Cannabis, mushrooms, zombie dealers)
- DRUG_SYSTEM_DEMO_F1_F2.md (Phase comparison + BUILD-TO-SPAWN)

### Identity & Features:
- HIPODEVIL666_TRADEMARK.md (Brand signature, philosophy)
- WHY_SPECIAL.md (10 unique selling points)
- ACCESSIBILITY_SLOVENIAN.md (Accessibility + language support)

### Technical:
- ELECTRON_STATUS_COMPLETE.md (Desktop app status)
- GLASBA_LICENCE_SUMMARY.md (Music + voiceover licenses)

### Session Log:
- SESSION_DNEVNIK_JAN_18_2026.md (Development diary)

## Key Highlights:

 20 biomes fully documented
 10-phase release strategy locked
 Drug empire system complete (BUILD-TO-SPAWN mechanics)
 HIPODEVIL666CITY confirmed (town name)
 Accessibility features documented (one-handed mode, color blind)
 Full Slovenian voiceover (21 tracks)
 Electron desktop app status
 Zoombucks currency (replaced €)
 Kevin MacLeod music (CC BY 3.0) + attribution

## Total Documentation:
- 16 new master files
- ~15,000+ lines of documentation
- Complete production roadmap
- All game systems documented

Ready for production! 🚀
2026-01-19 15:40:39 +01:00

132 lines
4.9 KiB
JavaScript

// --- 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) => {
// IGNORE AUDIO DECODING ERRORS (Phaser/Electron issue)
const msg = event.reason ? String(event.reason) : '';
if (msg.includes('Unable to decode audio data') || msg.includes('EncodingError') || msg.includes(':0:0')) {
console.warn('🔇 Ignored Critical Audio Error (Game continues):', msg);
event.preventDefault();
return;
}
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, // Fallback to Canvas (WebGL invisible objects issue)
width: 1024, // Larger viewport for better view
height: 768, // 4:3 aspect ratio
parent: 'game-container',
transparent: false, // FORCE OPAQUE CANVAS
backgroundColor: '#2a4a2a', // Green background default
pixelArt: false, // 🎨 SMOOTH FILMSKI LOOK (LINEAR filtering)
antialias: true, // 🎨 SMOOTH edges (mehki prehodi)
roundPixels: false, // 🎨 FLUID positioning (no kockanje)
render: {
pixelArt: false, // 🎨 LINEAR filtering (gladko)
antialias: true, // 🎨 Smooth transitions
roundPixels: false, // 🎨 Sub-pixel precision
transparent: true, // Allow HTML background to show through
clearBeforeRender: true,
powerPreference: 'high-performance',
premultipliedAlpha: true,
failIfMajorPerformanceCaveat: false,
// 🎨 LINEAR filtering for smooth tiles
mipmapFilter: 'NEAREST',
batchSize: 4096
},
physics: {
default: 'arcade',
arcade: {
gravity: { y: 0 },
debug: false
}
},
scene: [
BootScene,
PreloadScene,
AssetTestScene,
IntroScene,
PrologueScene,
EnhancedPrologueScene,
UltimatePrologueScene,
SystemsTestScene,
TestVisualAudioScene,
// DemoScene,
// DemoSceneEnhanced,
TiledTestScene,
StoryScene,
GameScene,
UIScene,
TownSquareScene
],
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 WEATHER MANAGER - Controls weather across ALL scenes
import('./managers/GlobalWeatherManager.js').then(module => {
const GlobalWeatherManager = module.default;
game.weatherManager = new GlobalWeatherManager(game);
console.log('🌦️ Global Weather Manager initialized!');
}).catch(err => {
console.error('❌ Failed to load GlobalWeatherManager:', err);
});
// 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!');