Fix score counting + obstacle removal

This commit is contained in:
Arne Keller 2022-01-30 12:29:00 +01:00
parent 32c91a6ecd
commit 0adc1fe818

View File

@ -376,7 +376,7 @@ function animate() {
for (let i = 0; i < cubes.length; i++) { 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]); scene.remove(cubes[i]);
cubes.splice(i, 1); cubes.splice(i, 1);
i--; i--;
@ -385,7 +385,7 @@ function animate() {
} }
if (removed >= 2 || score == 0) { if (removed >= 2 || score == 0) {
score += removed / 2; score += removed / 2;
removed = removed % 2; removed = 0;
document.getElementById("score").innerText = score; document.getElementById("score").innerText = score;
} }
if (borders.length == 0 || borders[borders.length - 1].position.z - camera.position.z > -1200) { if (borders.length == 0 || borders[borders.length - 1].position.z - camera.position.z > -1200) {