feat: Add color variations for natural elements and dynamic water colors
This commit is contained in:
@@ -22,19 +22,40 @@ function updateSand(x, y) {
|
||||
}
|
||||
|
||||
function updateWater(x, y) {
|
||||
// Update water color dynamically
|
||||
const metadata = getMetadata(x, y);
|
||||
if (metadata) {
|
||||
if (metadata.waterColorTimer === undefined) {
|
||||
metadata.waterColorTimer = 0;
|
||||
}
|
||||
|
||||
metadata.waterColorTimer++;
|
||||
|
||||
// Change color occasionally
|
||||
if (metadata.waterColorTimer > 20 && Math.random() < 0.1) {
|
||||
metadata.colorIndex = Math.floor(Math.random() * 10);
|
||||
metadata.waterColorTimer = 0;
|
||||
}
|
||||
|
||||
setMetadata(x, y, metadata);
|
||||
}
|
||||
|
||||
// Try to move down
|
||||
if (getPixel(x, y + 1) === EMPTY) {
|
||||
setPixel(x, y, EMPTY);
|
||||
setPixel(x, y + 1, WATER);
|
||||
moveMetadata(x, y, x, y + 1);
|
||||
}
|
||||
// Try to move down-left or down-right
|
||||
else if (getPixel(x - 1, y + 1) === EMPTY) {
|
||||
setPixel(x, y, EMPTY);
|
||||
setPixel(x - 1, y + 1, WATER);
|
||||
moveMetadata(x, y, x - 1, y + 1);
|
||||
}
|
||||
else if (getPixel(x + 1, y + 1) === EMPTY) {
|
||||
setPixel(x, y, EMPTY);
|
||||
setPixel(x + 1, y + 1, WATER);
|
||||
moveMetadata(x, y, x + 1, y + 1);
|
||||
}
|
||||
// Try to spread horizontally
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user