Fix bugs and add final colors

This commit is contained in:
GayLord
2024-10-23 16:27:37 +02:00
parent 6d9e0b3ef4
commit 037f929a8c
2 changed files with 54 additions and 45 deletions

View File

@@ -89,6 +89,7 @@ function createTetris() {
this.bgCanvas.width = this.fgCanvas.width = this.width;
this.bgCanvas.height = this.fgCanvas.height = this.height;
this.bgCtx = this.bgCanvas.getContext("2d");
this.fgCtx = this.fgCanvas.getContext("2d");
@@ -122,6 +123,8 @@ function createTetris() {
this.level = 0;
this.loseBlock = 0;
// init the board
this.board = [];
this.boardWidth = Math.floor(this.width / this.unitSize);
@@ -478,13 +481,20 @@ function createTetris() {
var width = window.innerWidth,
boardDiv = 20 * Math.round(window.innerWidth / 20),
boards = 8,
boards = 1,
bWidth = boardDiv / boards,
tetrisInstances = [];
let barsHeight = document.getElementsByClassName("secondary-nav")[0].clientHeight + document.getElementById("navbar").clientHeight;
let footer_size = document.getElementsByClassName("page-footer")[0].clientHeight;
let bheight = window.innerHeight - barsHeight - footer_size;
console.log(window.innerHeight, document.getElementsByClassName("secondary-nav")[0].clientHeight, document.getElementById("navbar").clientHeight);
for (var w = 0; w < boards; w++) {
tetrisInstances.push(
new Tetris(20 * Math.round((w * bWidth) / 20), 0, bWidth)
new Tetris(20 * Math.round((w * bWidth) / 20), barsHeight, bWidth, bheight)
);
}
}