This commit is contained in:
2025-12-12 00:13:55 +01:00
parent 158beec572
commit e15b429e75
17 changed files with 482 additions and 202 deletions

View File

@@ -208,14 +208,19 @@ class GameScene extends Phaser.Scene {
this.signposts = [];
// Path markers (using fence sprites as signposts)
const pathMarkers = [
{ x: 35, y: 35, label: '→ City' },
{ x: 50, y: 50, label: '← Farm' },
];
// ONLY if terrainSystem was successfully initialized
if (this.terrainSystem) {
const pathMarkers = [
{ x: 35, y: 35, label: '→ City' },
{ x: 50, y: 50, label: '← Farm' },
];
for (const marker of pathMarkers) {
this.terrainSystem.addDecoration(marker.x, marker.y, 'fence');
this.signposts.push({ gridX: marker.x, gridY: marker.y, label: marker.label });
for (const marker of pathMarkers) {
this.terrainSystem.addDecoration(marker.x, marker.y, 'fence');
this.signposts.push({ gridX: marker.x, gridY: marker.y, label: marker.label });
}
} else {
console.warn('⚠️ TerrainSystem not initialized - skipping signposts');
}
// Kamera sledi igralcu z gladko interpolacijo (lerp 0.1)
@@ -280,8 +285,8 @@ class GameScene extends Phaser.Scene {
// Initialize Save System
this.saveSystem = new SaveSystem(this);
// Auto-load if available
this.saveSystem.loadGame();
// Auto-load if available (DISABLED in SaveSystem!)
this.saveSystem.loadGame(); // Vrne false - ne naloži save-a!
// Debug Text
this.add.text(10, 10, 'NovaFarma Alpha v0.6', { font: '16px monospace', fill: '#ffffff' })
@@ -738,11 +743,11 @@ class GameScene extends Phaser.Scene {
if (this.terrainSystem.decorationsMap.has(key)) {
this.terrainSystem.removeDecoration(x, y);
}
// Make it grass or dirt - USE CORRECT TERRAIN TYPE OBJECT
// Make it DIRT for farming
if (this.terrainSystem.tiles[y] && this.terrainSystem.tiles[y][x]) {
this.terrainSystem.tiles[y][x].type = this.terrainSystem.terrainTypes.GRASS_FULL;
this.terrainSystem.tiles[y][x].type = 'dirt';
if (this.terrainSystem.tiles[y][x].sprite) {
this.terrainSystem.tiles[y][x].sprite.setTexture('grass');
this.terrainSystem.tiles[y][x].sprite.setTexture('dirt');
this.terrainSystem.tiles[y][x].sprite.setTint(0xffffff); // Clear tint
}
}

View File

@@ -41,6 +41,13 @@ class PreloadScene extends Phaser.Scene {
this.load.image('tree_blue_final', 'assets/tree_blue_final.png');
this.load.image('tree_dead_final', 'assets/tree_dead_final.png');
// STARDEW VALLEY FOREST TREES (NEW!)
this.load.image('tree_purple', 'assets/tree_purple.png');
this.load.image('tree_apple', 'assets/tree_apple.png');
this.load.image('tree_pear', 'assets/tree_pear.png');
this.load.image('tree_cherry', 'assets/tree_cherry.png');
this.load.image('tree_sapling', 'assets/tree_green_final.png'); // Reuse green as sapling
// NEW transparent tree/rock assets
this.load.image('tree_blue_new', 'assets/tree_blue_new.png'); // Keep for backup
@@ -53,6 +60,9 @@ class PreloadScene extends Phaser.Scene {
this.load.image('merchant_new', 'assets/merchant_new.png');
this.load.image('elite_zombie', 'assets/elite_zombie.png');
// Fence old for abandoned houses
this.load.image('fence_old', 'assets/fence_isometric.png'); // Reuse fence for old houses
// AI-Generated NPC Sprites (with cache-busting)
const cacheBust = Date.now();
this.load.image('cow', `assets/cow.png?v=${cacheBust}`);
@@ -191,6 +201,13 @@ class PreloadScene extends Phaser.Scene {
'tree_blue_final',
'tree_dead_final',
// STARDEW VALLEY FOREST TREES
'tree_purple',
'tree_apple',
'tree_pear',
'tree_cherry',
'tree_sapling',
// NEW transparent assets
'tree_blue_new',
'tree_green_new',
@@ -203,6 +220,7 @@ class PreloadScene extends Phaser.Scene {
'flowers_new',
'hill_sprite',
'fence',
'fence_old',
'gravestone',
// City content
'chest',
@@ -288,43 +306,51 @@ class PreloadScene extends Phaser.Scene {
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
const data = imageData.data;
// Remove backgrounds - IMPROVED CHECKBOARD DETECTION
// Remove backgrounds - ULTRA AGGRESSIVE MODE!
for (let i = 0; i < data.length; i += 4) {
const r = data[i];
const g = data[i + 1];
const b = data[i + 2];
const a = data[i + 3];
// Remove ALL grayscale colors (checkboard pattern)
// Checkboard has both light (204,204,204) and dark (153,153,153) squares
const isGrayscale = Math.abs(r - g) < 15 && Math.abs(g - b) < 15 && Math.abs(r - b) < 15;
// Skip if already transparent
if (a === 0) continue;
if (isGrayscale) {
// ULTRA-AGGRESSIVE: Remove ALL grays from 100-240
const isAnyGray = r >= 100 && r <= 240;
if (isAnyGray) {
data[i + 3] = 0; // Make transparent
}
}
// AGGRESSIVE: Remove ALL light backgrounds (AI-generated sprites)
const brightness = (r + g + b) / 3;
const isVeryLight = brightness > 170 && Math.abs(r - g) < 50 && Math.abs(g - b) < 50;
if (isVeryLight) {
// 1. Remove ALL grayscale colors (ANY shade of gray)
const isGrayscale = Math.abs(r - g) < 20 && Math.abs(g - b) < 20 && Math.abs(r - b) < 20;
if (isGrayscale && brightness > 80) {
data[i + 3] = 0; // Make transparent
continue;
}
// ULTRA AGGRESSIVE: Remove PURE WHITE backgrounds
const isWhite = r > 240 && g > 240 && b > 240;
if (isWhite) {
// 2. Remove ALL light/bright backgrounds (AI-generated sprites)
if (brightness > 150) {
data[i + 3] = 0; // Make transparent
continue;
}
// ULTRA AGGRESSIVE: Remove OFF-WHITE backgrounds (cream, beige)
const isOffWhite = brightness > 230 && Math.abs(r - g) < 20 && Math.abs(g - b) < 20;
if (isOffWhite) {
data[i + 3] = 0; // Make transparent
// 3. Remove PURE WHITE
if (r > 240 && g > 240 && b > 240) {
data[i + 3] = 0;
continue;
}
// 4. Remove OFF-WHITE / CREAM / BEIGE
if (brightness > 200 && Math.abs(r - g) < 30 && Math.abs(g - b) < 30) {
data[i + 3] = 0;
continue;
}
// 5. Remove PASTEL colors (low saturation, high brightness)
const maxRGB = Math.max(r, g, b);
const minRGB = Math.min(r, g, b);
const saturation = maxRGB === 0 ? 0 : (maxRGB - minRGB) / maxRGB;
if (saturation < 0.3 && brightness > 120) {
data[i + 3] = 0; // Remove low-saturation backgrounds
continue;
}
// Special: Remove brown/tan backgrounds (merchant sprite)