diff --git a/packages/topdown/tiles.js b/packages/topdown/tiles.js index b76ab3a..304466e 100644 --- a/packages/topdown/tiles.js +++ b/packages/topdown/tiles.js @@ -60,6 +60,10 @@ export class Tiles extends decorate(class {}) { return this; } + indexAt(position) { + return this.width * position[1] + position[0]; + } + packetsForUpdate() { const packetsForUpdate = this.updatePackets; this.updatePackets = []; @@ -117,7 +121,7 @@ export class Tiles extends decorate(class {}) { } tileAt(position) { - return this.data[position[1] * this.width + position[0]]; + return this.data[this.indexAt(position)]; } toJSON() {