My Output also says:
Nothing…
There is an error in the JavaScript console. If you press the K
key, for instance, you can see the following in the JavaScript console:
Uncaught ReferenceError: powerUp2 is not defined
at HTMLDocument.sendKeyDown (code.html:263)
code.html:277 Uncaught ReferenceError: powerUp2 is not defined
at HTMLDocument.sendKeyUp (code.html:277)
The line numbers are slightly confused, but are resulting when the clearInterval()
functions are called on line 260 and 281:
clearInterval(powerUp1);
These lines are correct. The reason for the error is that powerUp1
is not defined anywhere in the code and, unfortunately, the clearInterval()
function requires a defined value. To fix, change lines 248 and line 249. Those lines currently read:
var power1;
var power2;
Instead, they should declare powerUp1
and powerUp2
:
var powerUp1;
var powerUp2;
That will eliminate the errors. Sorry for your troubles – that is not an easy thing to debug, so it was good that posted your question here.
This fix should also get the launcher on the right working completely. The launcher on the left, launcher1
has a bug in it when you press the S
key. Look closely at the code and I think you can find the problem:
if (code == 'KeyS') {
clearInterval(powerUp1);
powerUp1 = setInterval(powerUpLauncher2, 20);
}
One last note: I do not think that if
statement with event.repeat
on line 256 is needed.
Hope that gets you working again. Let me know if you run into any other problems!
-Chris
I found the issue, at line:261 is powerUpLauncher2 instead of 1…