Fix river height, add horizontal river flow, soft edges, and intro sequence with grass growth
This commit is contained in:
@@ -119,10 +119,35 @@ export default class GrassSceneClean extends Phaser.Scene {
|
|||||||
|
|
||||||
// Note: We need to update tilePosition in update() loop to match camera scroll!
|
// Note: We need to update tilePosition in update() loop to match camera scroll!
|
||||||
|
|
||||||
// --- 2. RIVER SYSTEM (Removed) ---
|
// --- 2. RIVER SYSTEM (Infinite Scrolling - Horizontal) ---
|
||||||
/*
|
const riverHeight = 200; // Fixed height per user request
|
||||||
// Removed per user request ("odstrani vse")
|
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) ---
|
// --- 2.1 Prejšnji Stream System (Removed) ---
|
||||||
/*
|
/*
|
||||||
@@ -179,7 +204,10 @@ export default class GrassSceneClean extends Phaser.Scene {
|
|||||||
strokeThickness: 4
|
strokeThickness: 4
|
||||||
}).setScrollFactor(0).setDepth(1000); // UI always on top
|
}).setScrollFactor(0).setDepth(1000); // UI always on top
|
||||||
|
|
||||||
const GRASS_COUNT = 0; // TEMPORARILY DISABLED PER USER REQUEST (was 3000)
|
// --- INTRO SEQUENCE STATE ---
|
||||||
|
this.introStarted = false;
|
||||||
|
|
||||||
|
const GRASS_COUNT = 3000;
|
||||||
const SPREAD = 4000; // 4000px radius okoli centra
|
const SPREAD = 4000; // 4000px radius okoli centra
|
||||||
|
|
||||||
// Parametri reke za preverjanje (da ne sadimo trave v vodo)
|
// 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!
|
// POMEMBNO: Origin spodaj na sredini, da raste iz tal!
|
||||||
grass.setOrigin(0.5, 1.0);
|
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.setScale(0);
|
||||||
|
|
||||||
grass.setAngle(Math.random() * 20 - 10);
|
grass.setAngle(Math.random() * 20 - 10);
|
||||||
grass.setAlpha(0.8 + Math.random() * 0.2);
|
grass.setAlpha(0.8 + Math.random() * 0.2);
|
||||||
grass.setDepth(y); // Y-sort
|
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)
|
// Physics body (circle for better feel)
|
||||||
if (grass.body) {
|
if (grass.body) {
|
||||||
grass.body.setCircle(grass.width / 4);
|
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 ---
|
// --- 4. ITEMS & OBSTACLES ---
|
||||||
// REMOVED PER USER REQUEST
|
// REMOVED PER USER REQUEST
|
||||||
/*
|
/*
|
||||||
@@ -621,7 +646,7 @@ export default class GrassSceneClean extends Phaser.Scene {
|
|||||||
|
|
||||||
// 3. COLLIDERS
|
// 3. COLLIDERS
|
||||||
if (this.stream) this.physics.add.collider(this.kai, this.stream);
|
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);
|
// this.physics.add.collider(this.kai, this.obstaclesGroup);
|
||||||
|
|
||||||
// --- ANIMATIONS ---
|
// --- ANIMATIONS ---
|
||||||
@@ -659,7 +684,7 @@ export default class GrassSceneClean extends Phaser.Scene {
|
|||||||
|
|
||||||
// --- AMNESIA INIT ---
|
// --- AMNESIA INIT ---
|
||||||
// 1. PostFX Blur (Keep it for extra effect)
|
// 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)
|
// 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 ---
|
// --- AMNESIA SYSTEM ---
|
||||||
clearAmnesia() {
|
clearAmnesia() {
|
||||||
if (this.amnesiaBlur) {
|
if (this.amnesiaBlur) {
|
||||||
@@ -779,12 +824,10 @@ export default class GrassSceneClean extends Phaser.Scene {
|
|||||||
this.ground.tilePositionY = this.cameras.main.scrollY;
|
this.ground.tilePositionY = this.cameras.main.scrollY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. River Flow Animation (Removed)
|
// 2. River Flow Animation (Horizontal)
|
||||||
/*
|
|
||||||
if (this.river) {
|
if (this.river) {
|
||||||
this.river.tilePositionY -= 2.0;
|
this.river.tilePositionX += 2.0; // Flow to the left (texture moves right)
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// --- PLAYER MOVEMENT ---
|
// --- PLAYER MOVEMENT ---
|
||||||
const speed = 250;
|
const speed = 250;
|
||||||
|
|||||||
Reference in New Issue
Block a user