Update: Editor removal, Zoom fix, Cellar entrance, Pond restore
This commit is contained in:
@@ -7,11 +7,12 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
this.load.path = 'assets/';
|
||||
|
||||
// --- ASSETS ---
|
||||
// 1. Podlaga (Foundation)
|
||||
this.load.image('ground_base', 'DEMO_FAZA1/Ground/ground_dirt_patch.png');
|
||||
// 1. Podlaga (Foundation) - ZAMENJANO: Trava namesto blata
|
||||
this.load.image('ground_base', 'DEMO_FAZA1/tiles/trava_osnova.png');
|
||||
|
||||
// 2. Vodni kanali (Water)
|
||||
this.load.image('river_tile_seamless', 'DEMO_FAZA1/Environment/river_tile_seamless.png');
|
||||
this.load.image('water_clean_patch', 'DEMO_FAZA1/Environment/water_clean_patch.png');
|
||||
// this.load.image('river_tile_seamless', 'DEMO_FAZA1/Environment/river_tile_seamless.png');
|
||||
|
||||
// 3. Foliage
|
||||
// "Divja trava" - samo visoka trava
|
||||
@@ -70,6 +71,15 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
}
|
||||
|
||||
create() {
|
||||
// --- DYNAMIC ASSETS GENERATION ---
|
||||
// Generate 'hole' texture if it doesn't exist
|
||||
if (!this.textures.exists('hole')) {
|
||||
const holeGfx = this.make.graphics({ x: 0, y: 0, add: false });
|
||||
holeGfx.fillStyle(0x111111); // Almost black
|
||||
holeGfx.fillCircle(64, 64, 60);
|
||||
holeGfx.generateTexture('hole', 128, 128);
|
||||
}
|
||||
|
||||
// --- WORLD CONFIGURATION ---
|
||||
const TILE_SIZE = 128; // Standard grid size
|
||||
const MAP_WIDTH_TILES = 250;
|
||||
@@ -86,6 +96,7 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
|
||||
this.input.on('wheel', (pointer, gameObjects, deltaX, deltaY, deltaZ) => {
|
||||
// MACBOOK OPTIMIZATION: Prevent Zoom when hovering over Editor Sidebar
|
||||
/* REMOVED - Editor disabled
|
||||
if (this.editorEnabled) {
|
||||
const SIDEBAR_W = 320;
|
||||
const PALETTE_X = this.scale.width - SIDEBAR_W;
|
||||
@@ -93,6 +104,7 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
return; // Stop processing zoom if over sidebar
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// Zoom In/Out based on wheel delta
|
||||
// deltaY > 0 means scroll down (zoom out), deltaY < 0 means scroll up (zoom in)
|
||||
@@ -104,85 +116,46 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
});
|
||||
|
||||
// --- 1. PODLAGA (The Foundation) ---
|
||||
// Preprosta rešitev: Rjava barva ozadja + tekstura čez
|
||||
// ZAMENJANO: Zelena barva ozadja + trava tekstura
|
||||
|
||||
// 1. Nastavimo barvo ozadja na rjavo (barva zemlje)
|
||||
this.cameras.main.setBackgroundColor('#4e342e'); // Dark Brown
|
||||
// 1. Nastavimo barvo ozadja na temno zeleno (da se ujema s travo)
|
||||
this.cameras.main.setBackgroundColor('#2d4c1e');
|
||||
|
||||
const BG_W = this.scale.width * 2.5;
|
||||
const BG_H = this.scale.height * 2.5;
|
||||
|
||||
// 2. Uporabimo originalno sliko za tileSprite (Clean Slate)
|
||||
// 2. Uporabimo novo sliko za tileSprite (Grass Base)
|
||||
this.ground = this.add.tileSprite(this.scale.width / 2, this.scale.height / 2, BG_W, BG_H, 'ground_base');
|
||||
this.ground.setScrollFactor(0); // Sticks to camera
|
||||
this.ground.setDepth(-100);
|
||||
|
||||
// --- SCALE TEST ---
|
||||
// Za testiranje velikosti teksture:
|
||||
// Originalna velikost je verjetno majhna (npr. 512px).
|
||||
// Če želimo, da je vzorec večji, moramo povečati setTileScale.
|
||||
|
||||
// Trenutno: 1.0 (Originalna velikost)
|
||||
// Če je trava "preveč drobna", povečaj to številko (npr. 2.0).
|
||||
// Če je trava "preveč zrnata", zmanjšaj (npr. 0.5).
|
||||
this.ground.setTileScale(1.0);
|
||||
|
||||
// Note: We need to update tilePosition in update() loop to match camera scroll!
|
||||
|
||||
// --- 2. RIVER SYSTEM (Infinite Scrolling - Horizontal) ---
|
||||
const riverHeight = 200; // Fixed height per user request
|
||||
const riverY = WORLD_H / 2 + 300;
|
||||
// --- 2. RIVER SYSTEM (REMOVED) ---
|
||||
|
||||
// Horizontal River using tileSprite
|
||||
// 1. ROTATION FIX:
|
||||
// The texture 'river_tile_seamless' is vertical (banks on Left/Right).
|
||||
// We want horizontal flow (banks on Top/Bottom).
|
||||
// So we rotate the sprite by 90 degrees.
|
||||
// --- NEW: STATIC WATER POND (Ribnik) ---
|
||||
// Dodano nazaj na zahtevo uporabnika (posodobljen asset)
|
||||
this.pond = this.add.image(WORLD_W / 2 + 400, WORLD_H / 2 + 200, 'water_clean_patch');
|
||||
this.pond.setDepth(-45); // Malo nad tlemi
|
||||
this.pond.setScale(1.5);
|
||||
this.physics.add.existing(this.pond, true); // Static physics body
|
||||
|
||||
// --- CELLAR ENTRANCE (Hole) ---
|
||||
// Na poziciji Kai-a (WORLD_W / 2, WORLD_H / 2)
|
||||
this.hole = this.add.image(WORLD_W / 2, WORLD_H / 2, 'hole');
|
||||
this.hole.setDepth(-48); // On ground, below pond/items
|
||||
this.physics.add.existing(this.hole, true); // Static body for trigger
|
||||
|
||||
// When rotated 90 degrees:
|
||||
// - The sprite's "height" (local Y) becomes the screen width.
|
||||
// - The sprite's "width" (local X) becomes the screen height (river thickness).
|
||||
// So we initialize with swapped dimensions:
|
||||
// Width = riverHeight (which becomes vertical thickness after rotation)
|
||||
// Height = WORLD_W (which becomes horizontal length after rotation)
|
||||
|
||||
this.river = this.add.tileSprite(WORLD_W / 2, riverY, riverHeight, WORLD_W, 'river_tile_seamless');
|
||||
this.river.setAngle(90); // Rotate to horizontal
|
||||
this.river.setDepth(-50); // Above ground, below player
|
||||
|
||||
// Physics for River (Obstacle)
|
||||
this.physics.add.existing(this.river, true); // Static body
|
||||
|
||||
// 2. PHYSICS FIX for Rotated Sprite:
|
||||
// Arcade Physics bodies are AABB (Axis Aligned) and do NOT rotate with the sprite.
|
||||
// We must manually set the size to match the VISUAL shape on screen (Horizontal strip).
|
||||
this.river.body.setSize(WORLD_W, riverHeight * 0.8);
|
||||
|
||||
// Offset is relative to the Top-Left of the UNROTATED sprite (which is confusing).
|
||||
// Or simpler: Center the body on the sprite.
|
||||
this.river.body.center.set(this.river.x, this.river.y);
|
||||
// However, static bodies are tricky with offsets after creation.
|
||||
// Best approach: Resize body, then re-center it.
|
||||
// But since we use existing(), it might be offset.
|
||||
// Let's rely on manual offset if needed, or use a separate Zone if it fails.
|
||||
// Trying standard offset correction:
|
||||
// Visual Width = WORLD_W, Visual Height = riverHeight.
|
||||
// Unrotated Width = riverHeight, Unrotated Height = WORLD_W.
|
||||
// This mismatch often causes physics debug to look wrong.
|
||||
// Alternative: Use an invisible Zone for physics.
|
||||
|
||||
// Let's use an invisible rectangle for physics to be 100% safe and simple.
|
||||
this.river.body.enable = false; // Disable sprite body
|
||||
this.riverCollider = this.add.rectangle(WORLD_W / 2, riverY, WORLD_W, riverHeight * 0.8, 0x000000, 0);
|
||||
this.physics.add.existing(this.riverCollider, true);
|
||||
|
||||
// --- RIVER EDGES INTEGRATION (Soft Blend) ---
|
||||
// Create gradients to blend river edges with ground
|
||||
const edgeHeight = 32; // Narrower blend for tighter fit
|
||||
const riverGraphics = this.add.graphics();
|
||||
|
||||
// Top Edge: Solid Brown -> Transparent (Downwards)
|
||||
// 0x4e342e is the background brown
|
||||
riverGraphics.fillGradientStyle(0x4e342e, 0x4e342e, 0x4e342e, 0x4e342e, 1, 1, 0, 0);
|
||||
riverGraphics.fillRect(0, riverY - (riverHeight/2) - (edgeHeight/2) + 10, WORLD_W, edgeHeight); // +10 nudge in
|
||||
|
||||
// Bottom Edge: Transparent -> Solid Brown (Downwards)
|
||||
riverGraphics.fillGradientStyle(0x4e342e, 0x4e342e, 0x4e342e, 0x4e342e, 0, 0, 1, 1);
|
||||
riverGraphics.fillRect(0, riverY + (riverHeight/2) - (edgeHeight/2) - 10, WORLD_W, edgeHeight); // -10 nudge in
|
||||
|
||||
riverGraphics.setDepth(-49); // Above river
|
||||
|
||||
// --- 2.1 Prejšnji Stream System (Removed) ---
|
||||
/*
|
||||
// Center the whole construction
|
||||
const startX = WORLD_W / 2;
|
||||
@@ -246,16 +219,18 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
// Parametri reke za preverjanje (da ne sadimo trave v vodo)
|
||||
// Reka je na riverY, visoka je riverHeight
|
||||
// riverY je sredina reke
|
||||
const riverSafeZone = riverHeight / 2 + 50; // Polovica višine + malo rezerve
|
||||
// const riverSafeZone = riverHeight / 2 + 50; // REMOVED (River logic removed)
|
||||
|
||||
for (let i = 0; i < GRASS_COUNT; i++) {
|
||||
let x = (WORLD_W / 2) + (Math.random() * SPREAD * 2 - SPREAD);
|
||||
let y = (WORLD_H / 2) + (Math.random() * SPREAD * 2 - SPREAD);
|
||||
|
||||
// PREVERJANJE: Če je trava v reki, preskoči
|
||||
/*
|
||||
if (Math.abs(y - riverY) < riverSafeZone) {
|
||||
continue;
|
||||
}
|
||||
*/
|
||||
|
||||
// Randomizacija - samo divja trava
|
||||
let key = Math.random() > 0.5 ? 'grass_wild' : 'grass_wild_v2';
|
||||
@@ -321,7 +296,8 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
gameObject.y = dragY;
|
||||
});
|
||||
|
||||
// --- EDITOR MODE SYSTEM ---
|
||||
// --- EDITOR MODE SYSTEM (REMOVED) ---
|
||||
/*
|
||||
this.editorEnabled = true; // Enabled by default per user request
|
||||
this.selectedTile = 'path_tile_0';
|
||||
this.editorGroup = this.add.group(); // Saved tiles
|
||||
@@ -464,7 +440,7 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
this.ghostSprite.setVisible(state && this.selectedTile !== 'eraser_icon');
|
||||
console.log("Editor:", state);
|
||||
};
|
||||
toggleEditor(true); // Start visible per user request
|
||||
toggleEditor(false); // Start hidden per user request
|
||||
|
||||
// Toggle Key
|
||||
this.input.keyboard.on('keydown-E', () => {
|
||||
@@ -538,6 +514,7 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
this.updateAutotile(sx, sy);
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
// --- PREVIOUSLY GENERATED PROPS (Draggable Example) ---
|
||||
// Commented out per request "samo blatno potko"
|
||||
@@ -678,6 +655,14 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
|
||||
|
||||
// 3. COLLIDERS
|
||||
// Cellar Trigger
|
||||
if (this.hole) {
|
||||
this.physics.add.overlap(this.kai, this.hole, (player, hole) => {
|
||||
// Trigger logic (e.g., console log or event)
|
||||
// console.log("Standing on cellar entrance");
|
||||
});
|
||||
}
|
||||
|
||||
if (this.stream) this.physics.add.collider(this.kai, this.stream);
|
||||
// Collider with riverCollider (invisible zone) instead of rotated sprite
|
||||
if (this.riverCollider) this.physics.add.collider(this.kai, this.riverCollider);
|
||||
@@ -789,7 +774,8 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
}
|
||||
}
|
||||
|
||||
// --- AUTO-TILING SYSTEM ---
|
||||
// --- AUTO-TILING SYSTEM (REMOVED) ---
|
||||
/*
|
||||
getWaterBitmask(x, y) {
|
||||
// Check 4 neighbors: Top (1), Right (2), Bottom (4), Left (8)
|
||||
// Grid size is 128 (SNAP)
|
||||
@@ -849,6 +835,7 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
}
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
update(time, delta) {
|
||||
// --- PARALLAX & SCROLLING ---
|
||||
@@ -858,10 +845,12 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
this.ground.tilePositionY = this.cameras.main.scrollY;
|
||||
}
|
||||
|
||||
// 2. River Flow Animation (Horizontal)
|
||||
// 2. River Flow Animation (REMOVED)
|
||||
/*
|
||||
if (this.river) {
|
||||
this.river.tilePositionX += 2.0; // Flow to the left (texture moves right)
|
||||
}
|
||||
*/
|
||||
|
||||
// --- PLAYER MOVEMENT ---
|
||||
const speed = 250;
|
||||
|
||||
Reference in New Issue
Block a user