Tower class hierarchy

This commit is contained in:
Ian Gulliver
2021-05-11 02:57:17 +00:00
parent 495aeb6204
commit 0ff24fe806
28 changed files with 346 additions and 279 deletions

40
js/simple_tile_factory.js Normal file
View File

@@ -0,0 +1,40 @@
import { SimpleTile } from './simple_tile.js';
import { TileFactory } from './tile_factory.js';
export class SimpleTileFactory extends TileFactory {
constructor(width, height, name) {
super(width, height);
this.name = name;
this.animations = new Map();
}
add_animation(name, keyframes, options) {
this.animations.set(name, [keyframes, options]);
}
build(tileset) {
return new SimpleTile(this.width, this.height, `images/${tileset}/${this.name}.svg`, this.animations);
}
}
/*
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');
}
}
return mask;
}
*/
//# sourceMappingURL=simple_tile_factory.js.map