From c9c1e9c4c4124db9a2f7ea0114acf920917d28c7 Mon Sep 17 00:00:00 2001 From: Evert Prants Date: Fri, 29 Nov 2019 19:56:07 +0200 Subject: [PATCH] Clear the hook on new level --- src/game.js | 1 + src/player.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/game.js b/src/game.js index af248c5..0d13167 100644 --- a/src/game.js +++ b/src/game.js @@ -69,6 +69,7 @@ export class Game { this.time = this.roundTime this.level = Level.create(this.currentLevel, this.oh, this.gw, this.gh) this.goal = Math.floor(this.score / 2 + Game.calculateLevelScore(this.level) * 0.65) + this.player.hook.clear() } displayMessage (msg, time = 60) { diff --git a/src/player.js b/src/player.js index b688d2e..710729b 100644 --- a/src/player.js +++ b/src/player.js @@ -50,6 +50,14 @@ class Hook extends GameObject { ctx.restore() } + clear () { + this.obj = null + this.d = 0 + this.md = -1 + this.x = this.rx + this.y = this.ry + } + update (level) { if (this.d === 0 && this.r < FULL_ROTATION_EDGE && this.rd === 1) { this.r += 1