Shrani spremembe - 2026-02-02: Čiščenje kode, Electron build setup, GrassScene popravki
This commit is contained in:
@@ -23,7 +23,7 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
this.load.image('hay', 'DEMO_FAZA1/Items/hay_drop_0.png');
|
||||
this.load.image('trnje', 'DEMO_FAZA1/Obstacles/trnje.png');
|
||||
this.load.image('toxic_fog', 'DEMO_FAZA1/VFX/toxic_fog.png');
|
||||
this.load.image('amnesia_fog', 'DEMO_FAZA1/VFX/megla_ozadje.png');
|
||||
// this.load.image('amnesia_fog', 'DEMO_FAZA1/VFX/megla_ozadje.png'); // MISSING ASSET
|
||||
|
||||
// Generated Assets (Slices)
|
||||
// Trees
|
||||
@@ -32,7 +32,7 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
// Environment (Dead Nature, Fence, Water)
|
||||
for (let i = 0; i <= 8; i++) this.load.image(`dead_nature_${i}`, `DEMO_FAZA1/Environment/dead_nature_${i}.png`);
|
||||
for (let i = 0; i <= 2; i++) this.load.image(`fence_sign_${i}`, `DEMO_FAZA1/Environment/fence_sign_${i}.png`);
|
||||
for (let i = 0; i < 16; i++) this.load.image(`water_tile_${i}`, `DEMO_FAZA1/Environment/water_tile_${i}.png`);
|
||||
// for (let i = 0; i < 16; i++) this.load.image(`water_tile_${i}`, `DEMO_FAZA1/Environment/water_tile_${i}.png`); // MISSING ASSETS
|
||||
|
||||
// Misc Env
|
||||
this.load.image('sotor', 'DEMO_FAZA1/Environment/sotor.png');
|
||||
@@ -44,9 +44,9 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
veg.forEach(k => this.load.image(k, `DEMO_FAZA1/Vegetation/${k}.png`));
|
||||
|
||||
// Ground (Path)
|
||||
for (let i = 0; i < 16; i++) {
|
||||
this.load.image(`path_tile_${i}`, `DEMO_FAZA1/Ground/path_tile_${i}.png`);
|
||||
}
|
||||
// for (let i = 0; i < 16; i++) {
|
||||
// this.load.image(`path_tile_${i}`, `DEMO_FAZA1/Ground/path_tile_${i}.png`);
|
||||
// }
|
||||
// REPLACED STATIC KAI WITH SPRITE SHEET
|
||||
// Frame size 256x256 based on 1024x1024 sheet
|
||||
this.load.spritesheet('kai', 'DEMO_FAZA1/Characters/kai_walk_sheet.png', {
|
||||
@@ -159,45 +159,8 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
this.physics.add.existing(this.hole, true); // Static body for trigger
|
||||
|
||||
// --- REALISTIC TREE (Next to Pond) ---
|
||||
// Ribnik je na: WORLD_W / 2 + 400, WORLD_H / 2 + 200
|
||||
// Drevo postavimo levo zgoraj od ribnika
|
||||
const treeX = WORLD_W / 2 + 300;
|
||||
const treeY = WORLD_H / 2 + 150;
|
||||
// REMOVED PER USER REQUEST
|
||||
|
||||
// 1. Senca (Shadow) - Rahla temna elipsa za globino
|
||||
const shadow = this.add.ellipse(treeX, treeY + 10, 140, 60, 0x000000);
|
||||
shadow.setAlpha(0.3);
|
||||
shadow.setDepth(treeY - 1); // Malo pod drevesom
|
||||
|
||||
// 2. Drevo (Tree) - Z 'clipping' efektom
|
||||
const tree = this.add.image(treeX, treeY, 'tree_adult_0');
|
||||
// Nastavimo origin na (0.5, 0.9) namesto (0.5, 1.0).
|
||||
// To pomeni, da bo spodnjih 10% slike "pod" točko (x,y).
|
||||
// S tem ustvarimo efekt, da deblo "potone" v tla.
|
||||
tree.setOrigin(0.5, 0.9);
|
||||
tree.setDepth(treeY); // Y-sort na točki stika
|
||||
this.physics.add.existing(tree, true); // Collider
|
||||
// Manjši collider za deblo
|
||||
tree.body.setSize(60, 40);
|
||||
tree.body.setOffset(tree.width/2 - 30, tree.height * 0.9 - 20);
|
||||
|
||||
// 3. Trava okoli debla (Grass Masking / Feathering)
|
||||
// Postavimo par šopov trave točno na stik debla in tal, da skrijemo rob.
|
||||
for(let i=0; i<8; i++) {
|
||||
let angle = Math.random() * Math.PI * 2;
|
||||
let dist = Math.random() * 30; // Blizu debla
|
||||
let gx = treeX + Math.cos(angle) * dist;
|
||||
let gy = treeY + Math.sin(angle) * 10; // Sploščeno po Y osi (izometrično)
|
||||
|
||||
let grassKey = Math.random() > 0.5 ? 'grass_wild' : 'grass_wild_v2';
|
||||
let grass = this.add.image(gx, gy, grassKey);
|
||||
|
||||
grass.setScale(0.3 + Math.random() * 0.3); // Manjši šopi
|
||||
grass.setDepth(treeY + 2); // Malo NAD drevesom, da prekrijejo spodnji rob debla!
|
||||
grass.setOrigin(0.5, 1.0);
|
||||
grass.setTint(0xcccccc); // Rahlo temnejša trava (v senci drevesa)
|
||||
grass.setAlpha(0.9);
|
||||
}
|
||||
|
||||
/*
|
||||
// Center the whole construction
|
||||
@@ -254,13 +217,13 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
// --- INTRO SEQUENCE STATE ---
|
||||
this.introStarted = false;
|
||||
|
||||
const GRASS_COUNT = 0; // Disabled per user request
|
||||
const GRASS_COUNT = 2000; // Restored per user request
|
||||
const SPREAD = 4000; // 4000px radius okoli centra
|
||||
|
||||
// Parametri za izločanje trave (Pond & Hole)
|
||||
const pondX = WORLD_W / 2 + 400;
|
||||
const pondY = WORLD_H / 2 + 200;
|
||||
const pondRadius = 150; // Approx radius of pond
|
||||
const pondRadius = 600; // POVEČANO: Da odstranimo travo tudi okoli ribnika (Clearance)
|
||||
|
||||
const holeX = WORLD_W / 2;
|
||||
const holeY = WORLD_H / 2;
|
||||
@@ -306,6 +269,26 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
}
|
||||
}
|
||||
|
||||
// --- TREE PLANTATION (Initial Phase) ---
|
||||
const TREE_COUNT = 50;
|
||||
for (let i = 0; i < TREE_COUNT; i++) {
|
||||
let x = (WORLD_W / 2) + (Math.random() * SPREAD * 2 - SPREAD);
|
||||
let y = (WORLD_H / 2) + (Math.random() * SPREAD * 2 - SPREAD);
|
||||
|
||||
// Avoid Pond
|
||||
if (Phaser.Math.Distance.Between(x, y, pondX, pondY) < pondRadius) continue;
|
||||
// Avoid Hole
|
||||
if (Phaser.Math.Distance.Between(x, y, holeX, holeY) < holeRadius + 50) continue;
|
||||
|
||||
let tree = this.physics.add.image(x, y, 'drevo_faza_1');
|
||||
tree.setOrigin(0.5, 0.95); // Base of trunk
|
||||
tree.setDepth(y);
|
||||
tree.setScale(0.8 + Math.random() * 0.4);
|
||||
tree.body.setImmovable(true);
|
||||
tree.body.setSize(40, 30);
|
||||
tree.body.setOffset(tree.width/2 - 20, tree.height - 40);
|
||||
}
|
||||
|
||||
// --- INTRO LISTENER ---
|
||||
// Klik na podlago sproži rast trave in čiščenje amnezije
|
||||
this.input.on('pointerdown', () => {
|
||||
@@ -823,67 +806,7 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
}
|
||||
|
||||
// --- AUTO-TILING SYSTEM (REMOVED) ---
|
||||
/*
|
||||
getWaterBitmask(x, y) {
|
||||
// Check 4 neighbors: Top (1), Right (2), Bottom (4), Left (8)
|
||||
// Grid size is 128 (SNAP)
|
||||
const SNAP = 128;
|
||||
let mask = 0;
|
||||
|
||||
// Helper to check if a tile at (tx, ty) is water
|
||||
const isWater = (tx, ty) => {
|
||||
// Check existing tiles in editorGroup
|
||||
// This is O(N), for optimization use a Map in production
|
||||
let found = this.editorGroup.getChildren().find(c =>
|
||||
Math.abs(c.x - tx) < 10 && Math.abs(c.y - ty) < 10 &&
|
||||
c.texture.key.startsWith('water_tile_')
|
||||
);
|
||||
return !!found;
|
||||
};
|
||||
|
||||
if (isWater(x, y - SNAP)) mask += 1; // Top
|
||||
if (isWater(x + SNAP, y)) mask += 2; // Right
|
||||
if (isWater(x, y + SNAP)) mask += 4; // Bottom
|
||||
if (isWater(x - SNAP, y)) mask += 8; // Left
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
||||
updateAutotile(x, y) {
|
||||
const SNAP = 128;
|
||||
|
||||
// 1. Find the tile at x,y
|
||||
let tile = this.editorGroup.getChildren().find(c =>
|
||||
Math.abs(c.x - x) < 10 && Math.abs(c.y - y) < 10
|
||||
);
|
||||
|
||||
if (!tile || !tile.texture.key.startsWith('water_tile_')) return;
|
||||
|
||||
// 2. Calculate new mask
|
||||
let mask = this.getWaterBitmask(x, y);
|
||||
tile.setTexture(`water_tile_${mask}`);
|
||||
|
||||
// 3. Update neighbors
|
||||
const neighbors = [
|
||||
{ dx: 0, dy: -SNAP }, // Top
|
||||
{ dx: SNAP, dy: 0 }, // Right
|
||||
{ dx: 0, dy: SNAP }, // Bottom
|
||||
{ dx: -SNAP, dy: 0 } // Left
|
||||
];
|
||||
|
||||
neighbors.forEach(n => {
|
||||
let nx = x + n.dx;
|
||||
let ny = y + n.dy;
|
||||
let neighbor = this.editorGroup.getChildren().find(c =>
|
||||
Math.abs(c.x - nx) < 10 && Math.abs(c.y - ny) < 10
|
||||
);
|
||||
if (neighbor && neighbor.texture.key.startsWith('water_tile_')) {
|
||||
let nMask = this.getWaterBitmask(nx, ny);
|
||||
neighbor.setTexture(`water_tile_${nMask}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
/* Removed for cleanup */
|
||||
|
||||
update(time, delta) {
|
||||
// --- PARALLAX & SCROLLING ---
|
||||
@@ -894,11 +817,7 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
}
|
||||
|
||||
// 2. River Flow Animation (REMOVED)
|
||||
/*
|
||||
if (this.river) {
|
||||
this.river.tilePositionX += 2.0; // Flow to the left (texture moves right)
|
||||
}
|
||||
*/
|
||||
/* Removed for cleanup */
|
||||
|
||||
// --- PLAYER MOVEMENT ---
|
||||
const speed = 250;
|
||||
|
||||
Reference in New Issue
Block a user