Feature: Realistic Tree (Shadow + Clipping + Grass Masking)
This commit is contained in:
BIN
nova farma TRAE/assets/.DS_Store
vendored
BIN
nova farma TRAE/assets/.DS_Store
vendored
Binary file not shown.
BIN
nova farma TRAE/assets/DEMO_FAZA1/.DS_Store
vendored
BIN
nova farma TRAE/assets/DEMO_FAZA1/.DS_Store
vendored
Binary file not shown.
@@ -158,10 +158,48 @@ export default class GrassSceneClean extends Phaser.Scene {
|
|||||||
this.hole.setDepth(-48); // On ground, below pond/items
|
this.hole.setDepth(-48); // On ground, below pond/items
|
||||||
this.physics.add.existing(this.hole, true); // Static body for trigger
|
this.physics.add.existing(this.hole, true); // Static body for trigger
|
||||||
|
|
||||||
|
// --- REALISTIC TREE DEMO ---
|
||||||
|
// Lokacija: Malo levo od igralca
|
||||||
|
const treeX = WORLD_W / 2 - 300;
|
||||||
|
const treeY = WORLD_H / 2;
|
||||||
|
|
||||||
|
// 1. Senca (Shadow) - Rahla temna elipsa za globino
|
||||||
|
const shadow = this.add.ellipse(treeX, treeY + 10, 140, 60, 0x000000);
|
||||||
|
shadow.setAlpha(0.3);
|
||||||
|
shadow.setDepth(treeY - 1); // Malo pod drevesom
|
||||||
|
|
||||||
|
// 2. Drevo (Tree) - Z 'clipping' efektom
|
||||||
|
const tree = this.add.image(treeX, treeY, 'tree_adult_0');
|
||||||
|
// Nastavimo origin na (0.5, 0.9) namesto (0.5, 1.0).
|
||||||
|
// To pomeni, da bo spodnjih 10% slike "pod" točko (x,y).
|
||||||
|
// S tem ustvarimo efekt, da deblo "potone" v tla.
|
||||||
|
tree.setOrigin(0.5, 0.9);
|
||||||
|
tree.setDepth(treeY); // Y-sort na točki stika
|
||||||
|
this.physics.add.existing(tree, true); // Collider
|
||||||
|
// Manjši collider za deblo
|
||||||
|
tree.body.setSize(60, 40);
|
||||||
|
tree.body.setOffset(tree.width/2 - 30, tree.height * 0.9 - 20);
|
||||||
|
|
||||||
|
// 3. Trava okoli debla (Grass Masking / Feathering)
|
||||||
|
// Postavimo par šopov trave točno na stik debla in tal, da skrijemo rob.
|
||||||
|
for(let i=0; i<8; i++) {
|
||||||
|
let angle = Math.random() * Math.PI * 2;
|
||||||
|
let dist = Math.random() * 30; // Blizu debla
|
||||||
|
let gx = treeX + Math.cos(angle) * dist;
|
||||||
|
let gy = treeY + Math.sin(angle) * 10; // Sploščeno po Y osi (izometrično)
|
||||||
|
|
||||||
|
let grassKey = Math.random() > 0.5 ? 'grass_wild' : 'grass_wild_v2';
|
||||||
|
let grass = this.add.image(gx, gy, grassKey);
|
||||||
|
|
||||||
|
grass.setScale(0.3 + Math.random() * 0.3); // Manjši šopi
|
||||||
|
grass.setDepth(treeY + 2); // Malo NAD drevesom, da prekrijejo spodnji rob debla!
|
||||||
|
grass.setOrigin(0.5, 1.0);
|
||||||
|
grass.setTint(0xcccccc); // Rahlo temnejša trava (v senci drevesa)
|
||||||
|
grass.setAlpha(0.9);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Center the whole construction
|
// Center the whole construction
|
||||||
const startX = WORLD_W / 2;
|
|
||||||
const startY = WORLD_H / 2 - 300; // Start higher up to leave room for extensions
|
|
||||||
|
|
||||||
// Main Head (Pipe + Splash)
|
// Main Head (Pipe + Splash)
|
||||||
// Showing V7 Asset (Aggressive Clean + Transparent Green)
|
// Showing V7 Asset (Aggressive Clean + Transparent Green)
|
||||||
|
|||||||
Reference in New Issue
Block a user