code.html:163 Uncaught ReferenceError: riverPoints is not defined
at addPowerUp (code.html:163)
at resetPowerUps (code.html:154)
at reset (code.html:132)
at code.html:42
at _.html:9
Wth.
I dont understand it.
RiVeRpOiNt Is NoT dEfInEd…
WHY.
url:)https://is.gd/SgeNuY
The addPowerUp()
function is missing the riverPoint
argument. It should start as: function addPowerUp(riverPoint) {
. There are a couple of minor typos inside the function as well. The variable riverPoints
(plural) is used, but it should be just riverPoint
. And the line that defines shape
should be THREE.SphereGeometry
(it is missing and e
in the shared code).
The entire function should read:
function addPowerUp(riverPoint) {
ground.updateMatrixWorld();
var x = riverPoint.x + 4 * (Math.random() - 0.5);
var y = riverPoint.y;
var z = -0.5;
var p = new THREE.Vector3(x, y, z);
ground.localToWorld(p);
var shape = new THREE.SphereGeometry(0.25, 25, 18);
var cover = new THREE.MeshNormalMaterial();
var mesh = new Physijs.SphereMesh(shape, cover, 0);
mesh.position.copy(p);
mesh.powerUp = true;
scene.add(mesh);
mesh.addEventListener('collision', function() {
for (var i=0; 1<scene.children.length; i++) {
var obj = scene.children[i];
if (obj == mesh) scene.remove(obj);
}
scoreboard.addPoints(200);
scoreboard.message('Lecker!');
setTimeout(function() {scoreboard.clearMessage();}, 5*1000);
});
}