This commit is contained in:
Ian Gulliver
2021-05-08 20:30:37 +00:00
parent c3b890199d
commit f3dee2adf0
20 changed files with 39 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
import { TowerMap } from 'tower_map.js';
import { TowerMap } from './tower_map.js';
export function main() {
document.body.style.margin = '0';
@@ -10,5 +10,8 @@ export function main() {
container.style.height = '100vmin';
const map = new TowerMap(container);
map.draw();
map.set_size(20, 20);
map.set_tileset('tropical');
};
main();

View File

@@ -1,14 +1,23 @@
export class TowerMap {
#prnt;
#prnt: HTMLElement;
#tileset: string;
constructor(prnt: HTMLElement) {
this.#prnt = prnt;
this.#prnt.style.display = 'grid';
}
draw() {
this.#prnt.style.backgroundImage = 'url("images/land1.svg")';
this.#prnt.style.gridTemplateColumns = 'repeat(20, 1ft)';
this.#prnt.style.gridTemplateRows = 'repeat(20, 1ft)';
set_size(x: number, y: number) {
this.#prnt.style.gridTemplateColumns = `repeat(${x}, 1fr)`;
this.#prnt.style.gridTemplateRows = `repeat(${y}, 1fr)`;
}
set_tileset(set: string) {
this.#tileset = set;
this.#prnt.style.backgroundImage = this.get_url('land');
}
private get_url(tile: string) {
return `url("images/${this.#tileset}/${tile}.svg")`;
}
}