From 0adc1fe818332bb4f1de2f6d75f4c10ef218856d Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Sun, 30 Jan 2022 12:29:00 +0100 Subject: [PATCH] Fix score counting + obstacle removal --- game.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/game.js b/game.js index 8d4d3e2..4b55bbe 100644 --- a/game.js +++ b/game.js @@ -376,7 +376,7 @@ function animate() { for (let i = 0; i < cubes.length; i++) { - if (cubes[i].position.z > camera.position.z + cubes[i].geometry.parameters.radius * cubes[i].scale.x) { + if (cubes[i].position.z > camera.position.z + cubes[i].geometry.parameters.radius * cubes[i].scale.x + 20) { scene.remove(cubes[i]); cubes.splice(i, 1); i--; @@ -385,7 +385,7 @@ function animate() { } if (removed >= 2 || score == 0) { score += removed / 2; - removed = removed % 2; + removed = 0; document.getElementById("score").innerText = score; } if (borders.length == 0 || borders[borders.length - 1].position.z - camera.position.z > -1200) {