From 565bcc93002a749c5cce6071c705a1de07289aba Mon Sep 17 00:00:00 2001 From: cha0s Date: Mon, 27 May 2019 18:13:09 -0500 Subject: [PATCH] refactor: (setT|t)ileAt uses vector position --- packages/topdown/tiles.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/topdown/tiles.js b/packages/topdown/tiles.js index e7e2409..60b86b3 100644 --- a/packages/topdown/tiles.js +++ b/packages/topdown/tiles.js @@ -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() {