grid get/set helpers
This commit is contained in:
parent
11d1fbec34
commit
ad89545326
1 changed files with 9 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue