feat: Add color variations for natural elements and dynamic water colors

This commit is contained in:
Kacper Kostka (aider)
2025-04-04 12:22:15 +02:00
parent a86acfff3a
commit 8ef18f52ab
6 changed files with 113 additions and 8 deletions

View File

@@ -62,6 +62,16 @@ function setPixel(worldX, worldY, type) {
const index = localY * CHUNK_SIZE + localX;
chunk[index] = type;
// Assign random color index for natural elements
if (type === DIRT || type === GRASS || type === STONE || type === WOOD || type === LEAF) {
const colorIndex = Math.floor(Math.random() * 10);
setMetadata(worldX, worldY, { ...getMetadata(worldX, worldY) || {}, colorIndex });
}
else if (type === WATER) {
const colorIndex = Math.floor(Math.random() * 10);
setMetadata(worldX, worldY, { ...getMetadata(worldX, worldY) || {}, colorIndex, waterColorTimer: 0 });
}
}
function getPixel(worldX, worldY) {