From ec7f8f9522db6eeaf13246295e1ee2ac82d86024 Mon Sep 17 00:00:00 2001 From: "Kacper Kostka (aider)" Date: Sat, 5 Apr 2025 15:06:49 +0200 Subject: [PATCH] feat: Spawn tree seeds 3 pixels above surface for better growth --- js/world.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/js/world.js b/js/world.js index 2f648ad..2b57938 100644 --- a/js/world.js +++ b/js/world.js @@ -191,8 +191,10 @@ function generateSpecialChunk(chunkData, chunkX, playerChunkX) { } // Only place the seed if there are no other seeds nearby - if (!hasSeedNearby && seedY >= 0 && chunkData[(floorY - noiseHeight) * CHUNK_SIZE + x] === GRASS) { - chunkData[seedY * CHUNK_SIZE + x] = TREE_SEED; + // Place seed 3 pixels above the surface instead of just 1 + const elevatedSeedY = floorY - noiseHeight - 3; // 3 pixels above the grass + if (!hasSeedNearby && elevatedSeedY >= 0 && chunkData[(floorY - noiseHeight) * CHUNK_SIZE + x] === GRASS) { + chunkData[elevatedSeedY * CHUNK_SIZE + x] = TREE_SEED; // Add metadata for the tree seed const seedMetadata = { age: Math.floor(random() * 50), // Random initial age @@ -287,7 +289,7 @@ function generateSpecialChunk(chunkData, chunkX, playerChunkX) { if (chunkData[surfaceY * CHUNK_SIZE + x] === GRASS) { // Reduced from 25% to 10% chance for a tree seed at each valid position if (random() < 0.1) { - const seedY = surfaceY - 1; // Position above the grass + const seedY = surfaceY - 3; // Position 3 pixels above the grass instead of just 1 // Check if this position is at least 5 pixels away from any existing tree seed let tooClose = false;