Board.js 897 B

12345678910111213141516171819202122232425262728293031
  1. import { Point } from "../libraries/spatial/Point.js";
  2. import { Global } from "../libraries/Global.js";
  3. export class Board {
  4. constructor(state, x = 0, y = 0) {
  5. this.position = new Point(x, y);
  6. this.state = state;
  7. }
  8. update(delta) {
  9. }
  10. draw(ctx) {
  11. ctx.save()
  12. ctx.translate(this.position.x, this.position.y)
  13. ctx.strokeStyle = "magenta"
  14. let boardWidth = this.state.tileWidth * 11;
  15. let boardPadding = (Global.screenBounds.width - boardWidth) / 2
  16. for(let i = 0; i < 100; i++) {
  17. ctx.beginPath()
  18. ctx.rect(i % 10 * this.state.tileWidth + boardPadding + (this.state.tileWidth / 2), Math.floor(i / 10) * this.state.tileWidth + (this.state.tileWidth / 2), this.state.tileWidth, this.state.tileWidth)
  19. ctx.closePath();
  20. ctx.stroke();
  21. }
  22. ctx.restore();
  23. }
  24. }