refactor: (setT|t)ileAt uses vector position
This commit is contained in:
parent
6aec1875f7
commit
565bcc9300
|
@ -58,12 +58,12 @@ export class Tiles extends decorate(class {}) {
|
|||
return Rectangle.compose([0, 0], this.size);
|
||||
}
|
||||
|
||||
setTileAt(x, y, tile) {
|
||||
const oldTile = this.tileAt(x, y);
|
||||
setTileAt(position, tile) {
|
||||
const oldTile = this.tileAt(position);
|
||||
if (oldTile === tile) {
|
||||
return;
|
||||
}
|
||||
const index = y * this.width + x;
|
||||
const index = position[1] * this.width + position[0];
|
||||
if (index < 0 || index >= this.data.length) {
|
||||
return;
|
||||
}
|
||||
|
@ -99,8 +99,8 @@ export class Tiles extends decorate(class {}) {
|
|||
return slice;
|
||||
}
|
||||
|
||||
tileAt(x, y) {
|
||||
return this.data[y * this.width + x];
|
||||
tileAt(position) {
|
||||
return this.data[position[1] * this.width + position[0]];
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user