From eb460fbb161e76052b7bdd2c57afc65e2e99bc2e Mon Sep 17 00:00:00 2001 From: niliara-edu Date: Thu, 12 Dec 2024 13:51:59 +0100 Subject: place pieces --- src/stones.js | 43 ------------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 src/stones.js (limited to 'src/stones.js') diff --git a/src/stones.js b/src/stones.js deleted file mode 100644 index ebe0f9b..0000000 --- a/src/stones.js +++ /dev/null @@ -1,43 +0,0 @@ -import { Vector2, placeOnBoard } from "./engine/visual.js" -import { board } from "./board.js" - -const ASSETS_BLACK = "assets/black.png" -const ASSETS_WHITE = "assets/white.png" - - -export class Stone { - constructor({ - team = "black", - position = new Vector2(0, 0), - }) { - this.team = team - this.position = position - - this.create_span() - board.stones[position.y][position.x] = this - - this.update() - } - - create_span() { - this.span = document.createElement("span") - this.span.className = `stone ${this.team}` - - let img = document.createElement("img") - img.src = this.team == "black" ? ASSETS_BLACK : ASSETS_WHITE - this.span.appendChild(img) - - document.body.appendChild(this.span) - } - - update() { - let response = placeOnBoard({ - position: this.position, - board_size: board.size, - }) - - this.span.style.left = response.left - this.span.style.top = response.top - this.span.style.width = response.width - } -} -- cgit v1.2.3