-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrid.js
More file actions
61 lines (57 loc) · 1.62 KB
/
grid.js
File metadata and controls
61 lines (57 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
let grid;
function clearLines() {
let clearThisLine = true;
let keepClearing = true;
while (keepClearing) {
keepClearing = false;
for (let i = 0; i<22; i++) {
clearThisLine = true;
for (let j = 0; j<10; j++) {
if (grid[i][j] == "") {
clearThisLine = false;
break;
}
}
//console.log("clearing liens");
if (clearThisLine == true) {
keepClearing = true;
linesCleared += 1;
console.log(`Total Lines Cleared = ${linesCleared}`);
grid.splice(i, 1);
grid.splice(0, 0, ["", "", "", "", "", "", "", "", "", ""]);
}
}
}
delete activePiece;
canWeHold = true;
activePiece = new artifacts(nextPieceNo.shift());
nextPieceNo.push(gimmeShapeNo());
}
function drawLines(b) {
gc.strokeWeight(1);
gc.stroke(150);
for (let i = 1; i <= 9; i++) {
gc.line(i*b, 0, i*b, gc.height);
}
for (let i = 1; i <= 19; i++) {
gc.line(0, i*b, gc.width, i*b);
}
}
function initialSetupGrid() {
grid = [];
for (let i = 0; i<22; i++) {
grid.push([]);
for (let j = 0; j<10; j++) {
grid[i].push("");
}
}
}
function drawGrid() {
for (let i = 2; i<22; i++) {
for (let j = 0; j<10; j++) {
if (grid[i][j] != "") {
createIndividualblock((j)*blockSize, (i-2)*blockSize, grid[i][j], 2, gc.CORNER, gc);
}
}
}
}