click to replay

This commit is contained in:
Evert Prants 2019-11-29 19:49:51 +02:00
parent 3724fb1a4a
commit a9ab775de7
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
2 changed files with 9 additions and 1 deletions

View File

@ -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
}

View File

@ -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) {