feat: indexAt

This commit is contained in:
cha0s 2019-06-12 22:15:56 -05:00
parent 9e083a26c3
commit 0984263edb

View File

@ -60,6 +60,10 @@ export class Tiles extends decorate(class {}) {
return this; return this;
} }
indexAt(position) {
return this.width * position[1] + position[0];
}
packetsForUpdate() { packetsForUpdate() {
const packetsForUpdate = this.updatePackets; const packetsForUpdate = this.updatePackets;
this.updatePackets = []; this.updatePackets = [];
@ -117,7 +121,7 @@ export class Tiles extends decorate(class {}) {
} }
tileAt(position) { tileAt(position) {
return this.data[position[1] * this.width + position[0]]; return this.data[this.indexAt(position)];
} }
toJSON() { toJSON() {