38 lines
817 B
TypeScript
38 lines
817 B
TypeScript
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|