grid get/set helpers

This commit is contained in:
Tangent Wantwight 2024-01-12 21:36:00 -05:00
parent 11d1fbec34
commit ad89545326

View file

@ -22,6 +22,15 @@ class IslandGrid {
this.data = Array(width * height).fill(0);
this.xy = dim(width, height);
}
public get(x: number, y: number): number {
return this.data[this.xy(x, y)];
}
public set(x: number, y: number, tile: number) {
this.data[this.xy(x, y)] = tile;
console.log(x, y, this.xy(x, y), this.data[this.xy(x, y)]);
}
}
function renderIslands(islands: IslandGrid, cx: CanvasRenderingContext2D) {