Files
tower/ts/tower_map.ts

24 lines
551 B
TypeScript
Raw Normal View History

2021-05-08 13:00:59 -07:00
export class TowerMap {
2021-05-08 20:30:37 +00:00
#prnt: HTMLElement;
#tileset: string;
2021-05-08 13:00:59 -07:00
constructor(prnt: HTMLElement) {
this.#prnt = prnt;
this.#prnt.style.display = 'grid';
}
2021-05-08 20:30:37 +00:00
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")`;
2021-05-08 13:00:59 -07:00
}
}