feat: Add color variations for natural elements and dynamic water colors
This commit is contained in:
35
js/render.js
35
js/render.js
@@ -47,21 +47,39 @@ function render() {
|
||||
if (type === SAND) {
|
||||
ctx.fillStyle = SAND_COLOR;
|
||||
} else if (type === WATER) {
|
||||
ctx.fillStyle = WATER_COLOR;
|
||||
// Get water color from metadata with variation
|
||||
const metadata = getMetadata(chunkX * CHUNK_SIZE + x, chunkY * CHUNK_SIZE + y);
|
||||
const colorIndex = metadata && metadata.colorIndex !== undefined ? metadata.colorIndex : 0;
|
||||
ctx.fillStyle = WATER_COLORS[colorIndex];
|
||||
} else if (type === WALL) {
|
||||
ctx.fillStyle = WALL_COLOR;
|
||||
} else if (type === DIRT) {
|
||||
ctx.fillStyle = DIRT_COLOR;
|
||||
// Get dirt color from metadata with variation
|
||||
const metadata = getMetadata(chunkX * CHUNK_SIZE + x, chunkY * CHUNK_SIZE + y);
|
||||
const colorIndex = metadata && metadata.colorIndex !== undefined ? metadata.colorIndex : 0;
|
||||
ctx.fillStyle = DIRT_COLORS[colorIndex];
|
||||
} else if (type === STONE) {
|
||||
ctx.fillStyle = STONE_COLOR;
|
||||
// Get stone color from metadata with variation
|
||||
const metadata = getMetadata(chunkX * CHUNK_SIZE + x, chunkY * CHUNK_SIZE + y);
|
||||
const colorIndex = metadata && metadata.colorIndex !== undefined ? metadata.colorIndex : 0;
|
||||
ctx.fillStyle = STONE_COLORS[colorIndex];
|
||||
} else if (type === GRASS) {
|
||||
ctx.fillStyle = GRASS_COLOR;
|
||||
// Get grass color from metadata with variation
|
||||
const metadata = getMetadata(chunkX * CHUNK_SIZE + x, chunkY * CHUNK_SIZE + y);
|
||||
const colorIndex = metadata && metadata.colorIndex !== undefined ? metadata.colorIndex : 0;
|
||||
ctx.fillStyle = GRASS_COLORS[colorIndex];
|
||||
} else if (type === WOOD) {
|
||||
ctx.fillStyle = WOOD_COLOR;
|
||||
// Get wood color from metadata with variation
|
||||
const metadata = getMetadata(chunkX * CHUNK_SIZE + x, chunkY * CHUNK_SIZE + y);
|
||||
const colorIndex = metadata && metadata.colorIndex !== undefined ? metadata.colorIndex : 0;
|
||||
ctx.fillStyle = WOOD_COLORS[colorIndex];
|
||||
} else if (type === SEED) {
|
||||
ctx.fillStyle = SEED_COLOR;
|
||||
} else if (type === GRASS_BLADE) {
|
||||
ctx.fillStyle = GRASS_COLOR;
|
||||
// Use the same color variation as grass
|
||||
const metadata = getMetadata(chunkX * CHUNK_SIZE + x, chunkY * CHUNK_SIZE + y);
|
||||
const colorIndex = metadata && metadata.colorIndex !== undefined ? metadata.colorIndex : 0;
|
||||
ctx.fillStyle = GRASS_COLORS[colorIndex];
|
||||
} else if (type === FLOWER) {
|
||||
// Get flower color from metadata or use a default
|
||||
const metadata = getMetadata(chunkX * CHUNK_SIZE + x, chunkY * CHUNK_SIZE + y);
|
||||
@@ -69,7 +87,10 @@ function render() {
|
||||
} else if (type === TREE_SEED) {
|
||||
ctx.fillStyle = SEED_COLOR;
|
||||
} else if (type === LEAF) {
|
||||
ctx.fillStyle = LEAF_COLOR;
|
||||
// Get leaf color from metadata with variation
|
||||
const metadata = getMetadata(chunkX * CHUNK_SIZE + x, chunkY * CHUNK_SIZE + y);
|
||||
const colorIndex = metadata && metadata.colorIndex !== undefined ? metadata.colorIndex : 0;
|
||||
ctx.fillStyle = LEAF_COLORS[colorIndex];
|
||||
} else if (type === FIRE) {
|
||||
// Get fire color from metadata
|
||||
const metadata = getMetadata(chunkX * CHUNK_SIZE + x, chunkY * CHUNK_SIZE + y);
|
||||
|
||||
Reference in New Issue
Block a user