refactor: Reduce tree seed generation frequency and spacing

This commit is contained in:
Kacper Kostka (aider) 2025-04-05 15:03:57 +02:00
parent 4716cbe692
commit 170b8d0a85

View File

@ -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;