Skip to content

Commit e467245

Browse files
committed
last bugfix (hopefully)
1 parent 111e7d5 commit e467245

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.vscode

.vscode/settings.json

-3
This file was deleted.

tetris.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ class Tetris {
192192
this.score = 0;
193193
this.isGameOver = false;
194194
this.level = 0;
195+
this.lines = 0;
195196
fps = PAL_FPS[this.level];
196197
this.spawn();
197198
}
@@ -274,10 +275,7 @@ class Tetris {
274275

275276
if (dir == DOWN) {
276277
this.score++;
277-
if (this.score > this.highScore) {
278-
this.highScore = this.score;
279-
localStorage.setItem("highscore", this.score);
280-
}
278+
this.updateHighScore();
281279
}
282280

283281
if (wall == WALL) return;
@@ -373,10 +371,7 @@ class Tetris {
373371
fps = PAL_FPS[this.level];
374372
frameRate(fps);
375373
}
376-
if (this.score > this.highScore) {
377-
this.highScore = this.score;
378-
localStorage.setItem("highscore", this.score);
379-
}
374+
this.updateHighScore();
380375
}
381376

382377
checkWallOnMove(dir, coords) {
@@ -483,13 +478,21 @@ class Tetris {
483478
}
484479

485480
this.score += 2 * minDistance;
481+
this.updateHighScore();
486482

487483
for (let i = 0; i < coords.length; i++) {
488484
coords[i].y += minDistance;
489485
}
490486
return coords;
491487
}
492488

489+
updateHighScore() {
490+
if (this.score > this.highScore) {
491+
this.highScore = this.score;
492+
localStorage.setItem("highscore", this.score);
493+
}
494+
}
495+
493496
hardDrop() {
494497
let coords = this.hardDropCoords();
495498
this.applyBoxes(coords);

0 commit comments

Comments
 (0)