Remove occupancy grid -- map maker can handle it

This commit is contained in:
Ian Gulliver
2021-05-09 22:09:06 +00:00
parent 4651eeb335
commit 5e9a00ef76
12 changed files with 84 additions and 263 deletions

View File

@@ -11,28 +11,15 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
}
return privateMap.get(receiver);
};
var _name, _width, _height, _mask;
var _name, _width, _height;
export class Tile {
constructor(name, width, height, mask) {
constructor(name, width, height) {
_name.set(this, void 0);
_width.set(this, void 0);
_height.set(this, void 0);
_mask.set(this, void 0);
__classPrivateFieldSet(this, _name, name);
__classPrivateFieldSet(this, _width, width);
__classPrivateFieldSet(this, _height, height);
__classPrivateFieldSet(this, _mask, mask);
}
static rectangle(name, width, height) {
const mask = Array(width).fill(Array(height).fill(true));
return new Tile(name, width, height, mask);
}
static from_mask(name, mask_string) {
const mask = string_to_mask(mask_string);
return new Tile(name, mask.length, mask[0].length, mask);
}
get_mask() {
return __classPrivateFieldGet(this, _mask);
}
get_elem(tileset) {
const elem = document.createElement('div');
@@ -43,23 +30,29 @@ export class Tile {
return elem;
}
}
_name = new WeakMap(), _width = new WeakMap(), _height = new WeakMap(), _mask = new WeakMap();
function string_to_mask(mask_string) {
// mask_string: '\n+++\n+++\n'
const rows = mask_string.trim().split('\n');
// rows: ['+++', '+++']
const mask = [];
for (let x = 0; x < rows[0].length; x++) {
mask[x] = Array(rows.length);
_name = new WeakMap(), _width = new WeakMap(), _height = new WeakMap();
/*
function string_to_mask(mask_string: string): boolean[][] {
// mask_string: '\n+++\n+++\n'
const rows = mask_string.trim().split('\n');
// rows: ['+++', '+++']
const mask = [];
for (let x = 0; x < rows[0].length; x++) {
mask[x] = Array(rows.length);
}
// mask: [ [ empty, empty ], [ empty, empty ], [ empty, empty ] ]
for (let y = 0; y < rows.length; y++) {
const row = rows[y];
for (let x = 0; x < row.length; x++) {
const cell = row[x];
mask[x][y] = (cell.toUpperCase() == 'X');
}
// mask: [ [ empty, empty ], [ empty, empty ], [ empty, empty ] ]
for (let y = 0; y < rows.length; y++) {
const row = rows[y];
for (let x = 0; x < row.length; x++) {
const cell = row[x];
mask[x][y] = (cell.toUpperCase() == 'X');
}
}
return mask;
}
return mask;
}
*/
//# sourceMappingURL=tile.js.map