📦 Asset Cleanup: Consolidating new clean assets into 'NOVE_SLIKE', removing weird folder names, and setting up clean Start scene.

This commit is contained in:
2026-01-21 01:01:17 +01:00
parent aab61aaa51
commit 8436efa770
109 changed files with 131 additions and 428 deletions

View File

@@ -1,132 +1,12 @@
// --- 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');
}
import GrassScene from './scenes/GrassScene.js';
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,
MainMenuScene,
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
}
type: Phaser.AUTO,
width: window.innerWidth,
height: window.innerHeight,
backgroundColor: '#1a1a1a', // Temno siva, da slika izstopa
parent: 'body',
scene: [GrassScene]
};
// 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!');

39
src/scenes/GrassScene.js Normal file
View File

@@ -0,0 +1,39 @@
export default class GrassScene extends Phaser.Scene {
constructor() {
super({ key: 'GrassScene' });
}
preload() {
console.log("🌱 Loading Clean Assets...");
// 1. TERRAIN (From new 'assets/slike/environment' folder)
this.load.image('ground', 'assets/slike/environment/plot_watered.png');
// 2. UI (From new 'assets/slike/ui' folder)
this.load.image('buy_btn', 'assets/slike/ui/shop_11_buy_button.png');
}
create() {
console.log("✅ Scene Created. Placing Clean Assets...");
const { width, height } = this.cameras.main;
// A. BACKGROUND (Tiled Ground)
// Using tileSprite to repeat the texture across the screen
this.add.tileSprite(0, 0, width, height, 'ground')
.setOrigin(0, 0)
.setTileScale(4); // Scale up for retro look
// B. UI ELEMENT (Corner Test)
// Placing button in top-left corner
const btn = this.add.image(100, 100, 'buy_btn');
btn.setScale(2); // Make check visible
// C. LABEL
this.add.text(width / 2, height - 50, 'SOURCE: assets/slike/ (NEW)', {
fontFamily: 'monospace',
fontSize: '24px',
color: '#ffffff',
backgroundColor: '#000000'
}).setOrigin(0.5);
}
}