From a9ab775de7d30e25ffff2d81a3660a25f0a18fdc Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Fri, 29 Nov 2019 19:49:51 +0200 Subject: [PATCH] click to replay --- src/game.js | 8 ++++++++ src/index.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/game.js b/src/game.js index abf7e05..af248c5 100644 --- a/src/game.js +++ b/src/game.js @@ -137,6 +137,14 @@ export class Game { let s = 'Score: $' + this.score ctx.fillText(t, ctx.oX + this.gw / 2 - ctx.measureText(t).width / 2, ctx.oY + this.gh / 2 - 15) ctx.fillText(s, ctx.oX + this.gw / 2 - ctx.measureText(s).width / 2, ctx.oY + this.gh / 2 + 15) + if (ctx.mouse['btn0']) { + setTimeout(() => { + this.currentLevel = 0 + this.score = 0 + this.nextLevel() + this.state = 0 + }, 500) + } return } diff --git a/src/index.js b/src/index.js index d1ec907..d5e025d 100644 --- a/src/index.js +++ b/src/index.js @@ -9,7 +9,7 @@ const GameHeight = 720 let playing = true let player = new Player(GameWidth / 2 - 30, 25, GameHeight - 80) -let game = new Game(60, player, player.h + 60, GameWidth, GameHeight) +let game = new Game(10, player, player.h + 60, GameWidth, GameHeight) // Retranslate score function player.score = function (obj) {