export class Sprite { constructor(image_src, map) { this.element = document.createElement("img") this.element.src = image_src this.element.className = "sprite" this.map = map this.map.container.appendChild(this.element) this.x = 0 this.y = 0 this.hide() } #update_pos() { this.element.style.left = `${100/this.map.width*this.x}%`, this.element.style.top = `${100/this.map.height*this.y}%` } set_pos(x, y) { this.x = x this.y = y this.#update_pos() } add_pos(x, y) { this.x += x this.y += y this.#update_pos() } hide() { this.element.style.display = "none" } show() { this.element.style.display = "initial" } destory() { this.element.remove() } }