feat: Spawn tree seeds 3 pixels above surface for better growth

This commit is contained in:
Kacper Kostka (aider) 2025-04-05 15:06:49 +02:00
parent 0b96238226
commit ec7f8f9522

View File

@ -191,8 +191,10 @@ function generateSpecialChunk(chunkData, chunkX, playerChunkX) {
} }
// Only place the seed if there are no other seeds nearby // Only place the seed if there are no other seeds nearby
if (!hasSeedNearby && seedY >= 0 && chunkData[(floorY - noiseHeight) * CHUNK_SIZE + x] === GRASS) { // Place seed 3 pixels above the surface instead of just 1
chunkData[seedY * CHUNK_SIZE + x] = TREE_SEED; 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 // Add metadata for the tree seed
const seedMetadata = { const seedMetadata = {
age: Math.floor(random() * 50), // Random initial age age: Math.floor(random() * 50), // Random initial age
@ -287,7 +289,7 @@ function generateSpecialChunk(chunkData, chunkX, playerChunkX) {
if (chunkData[surfaceY * CHUNK_SIZE + x] === GRASS) { if (chunkData[surfaceY * CHUNK_SIZE + x] === GRASS) {
// Reduced from 25% to 10% chance for a tree seed at each valid position // Reduced from 25% to 10% chance for a tree seed at each valid position
if (random() < 0.1) { 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 // Check if this position is at least 5 pixels away from any existing tree seed
let tooClose = false; let tooClose = false;