From 34b044214cf7dbec2f39187da2d2ce3119884950 Mon Sep 17 00:00:00 2001 From: David Kotnik Date: Sat, 31 Jan 2026 10:59:30 +0100 Subject: [PATCH] Fix river height, add horizontal river flow, soft edges, and intro sequence with grass growth --- .../src/scenes/GrassScene_Clean.js | 97 +++++++++++++------ 1 file changed, 70 insertions(+), 27 deletions(-) diff --git a/nova farma TRAE/src/scenes/GrassScene_Clean.js b/nova farma TRAE/src/scenes/GrassScene_Clean.js index e5d0f85a3..7ea23a735 100644 --- a/nova farma TRAE/src/scenes/GrassScene_Clean.js +++ b/nova farma TRAE/src/scenes/GrassScene_Clean.js @@ -119,11 +119,36 @@ export default class GrassSceneClean extends Phaser.Scene { // Note: We need to update tilePosition in update() loop to match camera scroll! - // --- 2. RIVER SYSTEM (Removed) --- - /* - // Removed per user request ("odstrani vse") - */ - + // --- 2. RIVER SYSTEM (Infinite Scrolling - Horizontal) --- + const riverHeight = 200; // Fixed height per user request + const riverY = WORLD_H / 2 + 300; + + // Horizontal River using tileSprite + // Width = WORLD_W (to cover full map width) + this.river = this.add.tileSprite(WORLD_W / 2, riverY, WORLD_W, riverHeight, 'river_tile_seamless'); + this.river.setDepth(-50); // Above ground, below player + + // Physics for River (Obstacle) + this.physics.add.existing(this.river, true); // Static body + this.river.body.setSize(WORLD_W, riverHeight * 0.8); // Slightly smaller collision + this.river.body.setOffset(0, riverHeight * 0.1); + + // --- RIVER EDGES INTEGRATION (Soft Blend) --- + // Create gradients to blend river edges with ground + const edgeHeight = 64; + 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), WORLD_W, edgeHeight); + + // Bottom Edge: Transparent -> Solid Brown (Downwards) + riverGraphics.fillGradientStyle(0x4e342e, 0x4e342e, 0x4e342e, 0x4e342e, 0, 0, 1, 1); + riverGraphics.fillRect(0, riverY + (riverHeight/2) - (edgeHeight/2), WORLD_W, edgeHeight); + + riverGraphics.setDepth(-49); // Above river + // --- 2.1 Prejšnji Stream System (Removed) --- /* // Center the whole construction @@ -178,8 +203,11 @@ export default class GrassSceneClean extends Phaser.Scene { stroke: '#000000', strokeThickness: 4 }).setScrollFactor(0).setDepth(1000); // UI always on top + + // --- INTRO SEQUENCE STATE --- + this.introStarted = false; - const GRASS_COUNT = 0; // TEMPORARILY DISABLED PER USER REQUEST (was 3000) + const GRASS_COUNT = 3000; const SPREAD = 4000; // 4000px radius okoli centra // Parametri reke za preverjanje (da ne sadimo trave v vodo) @@ -205,28 +233,16 @@ export default class GrassSceneClean extends Phaser.Scene { // POMEMBNO: Origin spodaj na sredini, da raste iz tal! grass.setOrigin(0.5, 1.0); - let targetScale = 0.5 + Math.random() * 0.5; + // Shranimo targetScale v objekt, da ga uporabimo v tweenu + grass.targetScale = 0.5 + Math.random() * 0.5; - // Začetno stanje: skrita v zemlji + // Začetno stanje: skrita grass.setScale(0); grass.setAngle(Math.random() * 20 - 10); grass.setAlpha(0.8 + Math.random() * 0.2); grass.setDepth(y); // Y-sort - // Growth Tween - "Dviganje iz zemlje" - this.tweens.add({ - targets: grass, - scaleX: targetScale, - scaleY: targetScale, - duration: 800 + Math.random() * 800, // Malo počasneje - delay: Math.random() * 1500, - ease: 'Back.out', // Efekt "pop" ven - onComplete: () => { - // Ko zraste, lahko dodamo npr. wind effect (opcijsko) - } - }); - // Physics body (circle for better feel) if (grass.body) { grass.body.setCircle(grass.width / 4); @@ -234,6 +250,15 @@ export default class GrassSceneClean extends Phaser.Scene { } } + // --- INTRO LISTENER --- + // Klik na podlago sproži rast trave in čiščenje amnezije + this.input.on('pointerdown', () => { + if (!this.introStarted) { + this.introStarted = true; + this.startIntroSequence(); + } + }); + // --- 4. ITEMS & OBSTACLES --- // REMOVED PER USER REQUEST /* @@ -621,7 +646,7 @@ export default class GrassSceneClean extends Phaser.Scene { // 3. COLLIDERS if (this.stream) this.physics.add.collider(this.kai, this.stream); - // this.physics.add.collider(this.kai, this.riverCollider); // Removed + if (this.river) this.physics.add.collider(this.kai, this.river); // this.physics.add.collider(this.kai, this.obstaclesGroup); // --- ANIMATIONS --- @@ -659,7 +684,7 @@ export default class GrassSceneClean extends Phaser.Scene { // --- AMNESIA INIT --- // 1. PostFX Blur (Keep it for extra effect) - // this.amnesiaBlur = this.cameras.main.postFX.addBlur(0, 2, 2, 1); + this.amnesiaBlur = this.cameras.main.postFX.addBlur(0, 2, 2, 1); // 2. Overlay Texture (Megla Pozabe) /* @@ -693,6 +718,26 @@ export default class GrassSceneClean extends Phaser.Scene { */ } + // --- INTRO SEQUENCE --- + startIntroSequence() { + console.log("Starting Intro Sequence: Grass Growth + Amnesia Clear"); + + // 1. Grass Growth Animation + this.grassGroup.getChildren().forEach((grass, index) => { + this.tweens.add({ + targets: grass, + scaleX: grass.targetScale, // Use stored target scale + scaleY: grass.targetScale, + duration: 800 + Math.random() * 800, + delay: Math.random() * 1500, // Staggered start + ease: 'Back.out', + }); + }); + + // 2. Clear Amnesia (Blur Fade) + this.clearAmnesia(); + } + // --- AMNESIA SYSTEM --- clearAmnesia() { if (this.amnesiaBlur) { @@ -779,12 +824,10 @@ export default class GrassSceneClean extends Phaser.Scene { this.ground.tilePositionY = this.cameras.main.scrollY; } - // 2. River Flow Animation (Removed) - /* + // 2. River Flow Animation (Horizontal) if (this.river) { - this.river.tilePositionY -= 2.0; + this.river.tilePositionX += 2.0; // Flow to the left (texture moves right) } - */ // --- PLAYER MOVEMENT --- const speed = 250;