2024.js/island/render.ts

38 lines
817 B
TypeScript
Raw Normal View History

2024-01-13 11:34:25 -05:00
import { IslandGrid } from "./grid";
export function renderIslands(
islands: IslandGrid,
cx: CanvasRenderingContext2D
) {
for (let y = 0; y < islands.height; y++) {
for (let x = 0; x < islands.width; x++) {
const tile = islands.data[islands.xy(x, y)];
switch (tile) {
case 0:
cx.fillStyle = "blue";
break;
case 1:
cx.fillStyle = "yellow";
break;
case 2:
cx.fillStyle = "#00ff00";
break;
case 3:
cx.fillStyle = "#008800";
break;
case 4:
case 5:
case 6:
case 7:
case 8:
cx.fillStyle = "#666666";
break;
default:
cx.fillStyle = "#88aaff";
break;
}
cx.fillRect(x, y, 1, 1);
}
}
}