Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
//-------------------------------------------------------------------------

function play() { hide('start'); reset(); playing = true; }
function lose() { show('start'); setVisualScore(); playing = false; }
function lose() { show('start'); setVisualScore(); playing = false; invalidate(); drawGameOver(); }

function setVisualScore(n) { vscore = n || score; invalidateScore(); }
function setScore(n) { score = n; setVisualScore(n); }
Expand Down Expand Up @@ -395,6 +395,8 @@
ctx.strokeRect(0, 0, nx*dx - 1, ny*dy - 1); // court boundary
invalid.court = false;
}
if (!playing)
drawGameOver();
}

function drawNext() {
Expand Down Expand Up @@ -432,11 +434,19 @@
}

function drawBlock(ctx, x, y, color) {
ctx.fillStyle = color;
ctx.fillRect(x*dx, y*dy, dx, dy);
ctx.strokeRect(x*dx, y*dy, dx, dy)
}

ctx.fillStyle = color;
ctx.fillRect(x*dx, y*dy, dx, dy);
ctx.strokeRect(x*dx, y*dy, dx, dy)
}

function drawGameOver() {
ctx.fillStyle = 'black';
ctx.fillRect(0, 0, canvas.width, canvas.height/2 - 20);
ctx.fillStyle = 'white';
ctx.font = 'bold 30px Arial';
ctx.textAlign = 'center';
ctx.fillText('GAME OVER', canvas.width/2, canvas.height/2);
}
//-------------------------------------------------------------------------
// FINALLY, lets run the game
//-------------------------------------------------------------------------
Expand Down