diff --git a/src/main.js b/src/main.js index 621e8ae..8170479 100644 --- a/src/main.js +++ b/src/main.js @@ -54,9 +54,9 @@ function keyPressed() { // reset score and targets gun.remainingShots = TOT_SHOTS; score.shotLeft = TOT_SHOTS; - score.score = 0; + initTargets(); } } @@ -65,8 +65,14 @@ function initTargets() { // Create new targets from the factory // Remember to unsubscribe the previous targets and to subscribe the new ones const factory = TargetFactory.getInstance(); + gun.unsubscribeAll(); targets = factory.getRandomTargets(MAX_TARGETS, TARGET_WIDTH, 200); + gun.subscribe(score); + for (let target of targets) { + gun.subscribe(target); + target.subscribe(score); + } } // Do not touch these