stanje 4am

This commit is contained in:
2025-12-07 04:19:57 +01:00
parent 521468c797
commit 03a9cd46a2
20 changed files with 619 additions and 168 deletions

View File

@@ -350,6 +350,7 @@ class TerrainSystem {
if (x > 5 && x < this.width - 5 && y > 5 && y < this.height - 5) {
let decorType = null;
let maxHp = 1;
let scale = 1.0; // Default scale
if (terrainType.name.includes('grass')) { // Check ANY grass type
const rand = Math.random();
@@ -361,6 +362,20 @@ class TerrainSystem {
} else if (rand < 0.025) { // Reduced to 2.5% trees (optimum balance)
decorType = 'tree';
maxHp = 5;
// TREE SIZING LOGIC
// 20% Normal (1.0)
// 60% Medium (0.6-0.8)
// 20% Tiny (0.2)
const sizeRand = Math.random();
if (sizeRand < 0.2) {
scale = 0.25; // 20% Tiny (0.25 visible enough)
} else if (sizeRand < 0.8) {
scale = 0.6 + Math.random() * 0.2; // 60% Scale 0.6-0.8
} else {
scale = 1.0; // 20% Full size
}
} else if (rand < 0.03) {
decorType = 'gravestone'; // 💀 Nagrobniki
maxHp = 10; // Težje uničiti
@@ -381,7 +396,8 @@ class TerrainSystem {
type: decorType,
id: key,
maxHp: maxHp,
hp: maxHp
hp: maxHp,
scale: scale // Save scale
};
this.decorations.push(decorData);
@@ -608,7 +624,7 @@ class TerrainSystem {
));
}
sprite.setDepth(this.iso.getDepth(x, y));
sprite.setDepth(this.iso.getDepth(x, y) - 2000); // Tiles always in background
this.visibleTiles.set(key, sprite);
}
@@ -630,8 +646,9 @@ class TerrainSystem {
cropPos.x + this.offsetX,
cropPos.y + this.offsetY + this.iso.tileHeight / 2 + elevationOffset
);
// Crop depth = Y pos
const depth = this.iso.getDepth(x, y);
sprite.setDepth(depth + 1); // Just slightly above tile
sprite.setDepth(depth);
this.visibleCrops.set(key, sprite);
}
@@ -658,8 +675,13 @@ class TerrainSystem {
);
const depth = this.iso.getDepth(x, y);
if (decor.type === 'flower') sprite.setDepth(depth + 1);
else sprite.setDepth(depth + 1000); // Taller objects update depth
// Depth strategy: Base of object sorting.
// Add small offset based on type if needed, but mainly use Y
sprite.setDepth(depth);
// Apply scale if present
if (decor.scale) sprite.setScale(decor.scale);
else sprite.setScale(1);
sprite.flipX = (x + y) % 2 === 0;