From 170b8d0a85d82b1a36c5c08861e3c231cca36119 Mon Sep 17 00:00:00 2001 From: "Kacper Kostka (aider)" Date: Sat, 5 Apr 2025 15:03:57 +0200 Subject: [PATCH] refactor: Reduce tree seed generation frequency and spacing --- js/world.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/js/world.js b/js/world.js index 2be0bb3..d990f2c 100644 --- a/js/world.js +++ b/js/world.js @@ -174,8 +174,8 @@ function generateSpecialChunk(chunkData, chunkX, playerChunkX) { } } - // Randomly spawn tree seeds on grass - if (random() < 0.08) { // 8% chance for a tree seed on grass + // Randomly spawn tree seeds on grass (reduced frequency) + if (random() < 0.03) { // Reduced from 8% to 3% chance for a tree seed on grass const seedY = floorY - noiseHeight - 1; // Position above the grass if (seedY >= 0 && chunkData[(floorY - noiseHeight) * CHUNK_SIZE + x] === GRASS) { chunkData[seedY * CHUNK_SIZE + x] = TREE_SEED; @@ -262,15 +262,15 @@ function generateSpecialChunk(chunkData, chunkX, playerChunkX) { } } - // Add additional tree seeds scattered throughout the terrain - for (let x = 0; x < CHUNK_SIZE; x += 5 + Math.floor(random() * 10)) { // Space them out + // Add additional tree seeds scattered throughout the terrain (with increased spacing and reduced chance) + for (let x = 0; x < CHUNK_SIZE; x += 15 + Math.floor(random() * 20)) { // Increased spacing from 5-15 to 15-35 const height = heightMap[x]; const surfaceY = floorY - height; // Only place seeds on grass if (chunkData[surfaceY * CHUNK_SIZE + x] === GRASS) { - // 25% chance for a tree seed at each valid position - if (random() < 0.25) { + // 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 if (seedY >= 0) { chunkData[seedY * CHUNK_SIZE + x] = TREE_SEED;