Implementacija neskončne reke z animacijo toka
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 281 KiB |
@@ -10,9 +10,8 @@ export default class GrassSceneClean extends Phaser.Scene {
|
|||||||
// 1. Podlaga (Foundation)
|
// 1. Podlaga (Foundation)
|
||||||
this.load.image('ground_base', 'DEMO_FAZA1/Ground/ground_dirt_patch.png');
|
this.load.image('ground_base', 'DEMO_FAZA1/Ground/ground_dirt_patch.png');
|
||||||
|
|
||||||
// 2. Vodni kanali (Water) - NEW CLEAN ASSET V7 (Aggressive Clean)
|
// 2. Vodni kanali (Water)
|
||||||
this.load.image('stream_final_v7', 'DEMO_FAZA1/Environment/stream_final_v7.png');
|
this.load.image('river_tile_seamless', 'DEMO_FAZA1/Environment/river_tile_seamless.png');
|
||||||
// Removed extensions for now
|
|
||||||
|
|
||||||
// 3. Foliage
|
// 3. Foliage
|
||||||
// "Divja trava" - samo visoka trava
|
// "Divja trava" - samo visoka trava
|
||||||
@@ -124,8 +123,36 @@ 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. STREAM SYSTEM (Head + Extensions) ---
|
// --- 2. RIVER SYSTEM (Infinite Scrolling) ---
|
||||||
// REMOVED PER USER REQUEST (Clean Start)
|
// Ustvarimo neskončno reko čez celo mapo (navpično)
|
||||||
|
// Predvidevamo, da je river_tile_seamless.png širine 128px (ali več) in se ponavlja navpično
|
||||||
|
|
||||||
|
const riverX = WORLD_W / 2 + 300; // Desno od centra
|
||||||
|
// Uporabimo tileSprite, ki sega od vrha do dna sveta
|
||||||
|
// Višina = WORLD_H (32000px), Širina = originalna širina slike (npr. 256px)
|
||||||
|
|
||||||
|
// Najprej dobimo teksturo, da preverimo dimenzije
|
||||||
|
const riverTex = this.textures.get('river_tile_seamless').getSourceImage();
|
||||||
|
const riverW = riverTex.width;
|
||||||
|
|
||||||
|
this.river = this.add.tileSprite(riverX, WORLD_H / 2, riverW, WORLD_H, 'river_tile_seamless');
|
||||||
|
this.river.setDepth(-50); // Nad zemljo (-100), pod igralcem (Y)
|
||||||
|
|
||||||
|
// FIZIKA: Reka je ovira (ne moreš čeznjo)
|
||||||
|
this.physics.add.existing(this.river, true); // Static body
|
||||||
|
// Nastavimo collider malo ožji od slike, da lahko stopiš na breg
|
||||||
|
this.river.body.setSize(riverW * 0.6, WORLD_H);
|
||||||
|
this.river.body.setOffset(riverW * 0.2, 0);
|
||||||
|
|
||||||
|
// Dodamo kolizijo z igralcem (ko bo ustvarjen)
|
||||||
|
// To naredimo kasneje v create() ali pa shranimo referenco za update
|
||||||
|
|
||||||
|
// "ZAKOPANA V ZEMLJO" - Vizualni trik
|
||||||
|
// Ker je slika že narisana z bregovi, samo dodamo malo sence, če je treba
|
||||||
|
// Ali pa rahlo temnejši tint, da izgleda globlje
|
||||||
|
this.river.setTint(0xdddddd); // Rahlo zatemnimo za globino
|
||||||
|
|
||||||
|
// --- 2.1 Prejšnji Stream System (Removed) ---
|
||||||
/*
|
/*
|
||||||
// Center the whole construction
|
// Center the whole construction
|
||||||
const startX = WORLD_W / 2;
|
const startX = WORLD_W / 2;
|
||||||
@@ -610,8 +637,10 @@ export default class GrassSceneClean extends Phaser.Scene {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Collider Stream <-> Kai
|
// 3. COLLIDERS
|
||||||
// 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.river); // Nova reka
|
||||||
|
// this.physics.add.collider(this.kai, this.obstaclesGroup);
|
||||||
|
|
||||||
// --- ANIMATIONS ---
|
// --- ANIMATIONS ---
|
||||||
// 0-3: Down, 4-7: Left, 8-11: Right, 12-15: Up
|
// 0-3: Down, 4-7: Left, 8-11: Right, 12-15: Up
|
||||||
@@ -760,26 +789,22 @@ export default class GrassSceneClean extends Phaser.Scene {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update(time, delta) {
|
||||||
// --- GROUND INFINITE SCROLL ---
|
// --- PARALLAX & SCROLLING ---
|
||||||
|
// 1. Ground Infinite Scroll
|
||||||
if (this.ground) {
|
if (this.ground) {
|
||||||
this.ground.tilePositionX = this.cameras.main.scrollX;
|
this.ground.tilePositionX = this.cameras.main.scrollX;
|
||||||
this.ground.tilePositionY = this.cameras.main.scrollY;
|
this.ground.tilePositionY = this.cameras.main.scrollY;
|
||||||
// No movement of x/y needed for scrollFactor(0)
|
}
|
||||||
|
|
||||||
|
// 2. River Flow Animation
|
||||||
|
// Premikamo tilePositionY, da voda "teče" navzdol
|
||||||
|
// Hitrost: 0.5px na frame (prilagodi po želji)
|
||||||
|
if (this.river) {
|
||||||
|
this.river.tilePositionY -= 2.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- FOG MOVEMENT ---
|
// --- PLAYER MOVEMENT ---
|
||||||
/*
|
|
||||||
if (this.fog1) {
|
|
||||||
this.fog1.tilePositionX += 0.5;
|
|
||||||
this.fog1.tilePositionY += 0.2;
|
|
||||||
}
|
|
||||||
if (this.fog2) {
|
|
||||||
this.fog2.tilePositionX -= 0.3;
|
|
||||||
this.fog2.tilePositionY += 0.1;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
const speed = 250;
|
const speed = 250;
|
||||||
this.kai.setVelocity(0);
|
this.kai.setVelocity(0);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user