Skip to content

Commit

Permalink
Update Breakout game
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki0418 committed Nov 3, 2020
1 parent 143d9f5 commit 5d0dc04
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion breakout/breakout.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ let ctx = canvas.getContext('2d');
let ball;
let bar;
let blocks = [];
let deletedBlocks = 0;
let score;
let isGameEnd = false;
const numBlockX = 10;
Expand Down Expand Up @@ -48,7 +49,7 @@ function drow() {
block.update();
});

if(isGameEnd || blocks.length == 0) {
if(isGameEnd || blocks.length == deletedBlocks) {
endGame();
} else {
window.requestAnimationFrame(drow);
Expand Down Expand Up @@ -216,6 +217,7 @@ function Block(x, y) {
this.removed = true;
this.clear();
ball.hitBlock();
++deletedBlocks;
score.addScore();
}
}
Expand Down

0 comments on commit 5d0dc04

Please sign in to comment.