The script actually prints ERROR, so delta must be equal to 0.
That conclusion isn't true at all. It could also be null
, or undefined
, or in this case... NaN
. Don't assume, validate:
console.log(delta);
The reason is because you re-declare local variables and never define them.
This:
function input_a(a)
Should be this:
function input_a()
Repeat for all of the other functions. This is because having those parameters means that any time you reference that variable within the function you're referencing the one that was passed to it, not the global one. And you don't pass anything to the functions, but are instead trying to use global variables.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…