add tile merging
This commit is contained in:
+14
-1
@@ -62,10 +62,23 @@ Grid.prototype.cellOccupied = function (cell) {
|
||||
};
|
||||
|
||||
Grid.prototype.cellContent = function (cell) {
|
||||
return this.cells[cell.x][cell.y];
|
||||
if (this.withinBounds(cell)) {
|
||||
return this.cells[cell.x][cell.y];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
// Inserts a tile at its position
|
||||
Grid.prototype.insertTile = function (tile) {
|
||||
this.cells[tile.x][tile.y] = tile;
|
||||
};
|
||||
|
||||
Grid.prototype.removeTile = function (tile) {
|
||||
this.cells[tile.x][tile.y] = null;
|
||||
};
|
||||
|
||||
Grid.prototype.withinBounds = function (position) {
|
||||
return position.x >= 0 && position.x < this.size &&
|
||||
position.y >= 0 && position.y < this.size;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user