Posodobitev trave (samo divja) in animacija rasti iz tal
This commit is contained in:
@@ -8,17 +8,16 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
|
||||
// --- ASSETS ---
|
||||
// 1. Podlaga (Foundation)
|
||||
// this.load.image('ground_base', 'DEMO_FAZA1/Ground/tla_trava_tekstura.png'); // Removed by user
|
||||
this.load.image('ground_base', 'DEMO_FAZA1/Ground/ground_dirt_patch.png');
|
||||
|
||||
// 2. Vodni kanali (Water) - NEW CLEAN ASSET V7 (Aggressive Clean)
|
||||
this.load.image('stream_final_v7', 'DEMO_FAZA1/Environment/stream_final_v7.png');
|
||||
// Removed extensions for now
|
||||
|
||||
// 3. Foliage
|
||||
this.load.image('grass_dense', 'DEMO_FAZA1/Vegetation/grass_cluster_dense.png');
|
||||
this.load.image('grass_tall', 'DEMO_FAZA1/Vegetation/visoka_trava.png');
|
||||
this.load.image('grass_v2', 'DEMO_FAZA1/Vegetation/visoka_trava_v2.png');
|
||||
this.load.image('grass_sop', 'DEMO_FAZA1/Vegetation/trava_sop.png');
|
||||
// "Divja trava" - samo visoka trava
|
||||
this.load.image('grass_wild', 'DEMO_FAZA1/Vegetation/visoka_trava.png');
|
||||
this.load.image('grass_wild_v2', 'DEMO_FAZA1/Vegetation/visoka_trava_v2.png');
|
||||
|
||||
// 4. Items & Charts
|
||||
this.load.image('hay', 'DEMO_FAZA1/Items/hay_drop_0.png');
|
||||
@@ -109,8 +108,13 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
// OPTIMIZATION: Instead of one massive 32000x32000 tileSprite which crashes WebGL,
|
||||
// we use a smaller one that follows the camera (Infinite Scroll technique).
|
||||
|
||||
// Removed ground_base tileSprite since texture is missing.
|
||||
// Using Background Color instead.
|
||||
// Size it to cover the screen even when zoomed out (0.5x zoom -> need 2x size)
|
||||
const BG_W = this.scale.width * 2.5;
|
||||
const BG_H = this.scale.height * 2.5;
|
||||
|
||||
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);
|
||||
|
||||
// Note: We need to update tilePosition in update() loop to match camera scroll!
|
||||
|
||||
@@ -177,43 +181,41 @@ export default class GrassSceneClean extends Phaser.Scene {
|
||||
let x = (WORLD_W / 2) + (Math.random() * SPREAD * 2 - SPREAD);
|
||||
let y = (WORLD_H / 2) + (Math.random() * SPREAD * 2 - SPREAD);
|
||||
|
||||
// Randomizacija z novimi tipi trave
|
||||
let rand = Math.random();
|
||||
let key;
|
||||
if (rand < 0.4) key = 'grass_dense';
|
||||
else if (rand < 0.7) key = 'grass_tall';
|
||||
else if (rand < 0.9) key = 'grass_v2';
|
||||
else key = 'grass_sop';
|
||||
// Randomizacija - samo divja trava
|
||||
let key = Math.random() > 0.5 ? 'grass_wild' : 'grass_wild_v2';
|
||||
|
||||
// Ustvari travo in jo dodaj v grupo
|
||||
let grass = this.grassGroup.create(x, y, key);
|
||||
|
||||
// POMEMBNO: Origin spodaj na sredini, da raste iz tal!
|
||||
grass.setOrigin(0.5, 1.0);
|
||||
|
||||
let targetScale = 0.5 + Math.random() * 0.5;
|
||||
grass.setScale(0); // Start at 0 for growth animation
|
||||
|
||||
// Začetno stanje: skrita v zemlji
|
||||
grass.setScale(0);
|
||||
|
||||
grass.setAngle(Math.random() * 20 - 10);
|
||||
grass.setAlpha(0.8 + Math.random() * 0.2);
|
||||
grass.setDepth(y); // Y-sort
|
||||
|
||||
// Growth Tween
|
||||
// Growth Tween - "Dviganje iz zemlje"
|
||||
this.tweens.add({
|
||||
targets: grass,
|
||||
scaleX: targetScale,
|
||||
scaleY: targetScale,
|
||||
duration: 500 + Math.random() * 500,
|
||||
delay: Math.random() * 1000,
|
||||
ease: 'Back.out'
|
||||
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);
|
||||
grass.body.setOffset(grass.width / 4, grass.height / 4);
|
||||
}
|
||||
|
||||
if (key === 'grass_tall') {
|
||||
grass.setOrigin(0.5, 0.9);
|
||||
grass.setDepth(y);
|
||||
} else {
|
||||
grass.setDepth(y - 50);
|
||||
grass.body.setOffset(grass.width / 4, grass.height / 2); // Adjusted for bottom origin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user