I have a syntax error and an undefined variable error in a short piece of code. I’ve posted the code and an run-copy of it on the above link of mine, under game program errors.
If anyone can direct me on how to correct these, I’d appreciate it greatly. I’ve also published an ALT attempt I can’t get to work as it should, also listed on that web page selection. Thanks!
Ooops, I forgot to answer this one.
The problem is to do with you moveGuy variable. First you declare it in window.onload and then you redeclare it late whilst trying to add one to it in the canvas click event var moveGuy = moveGuy + 1; . So to fix it you need to change the second on to moveGuy = moveGuy + 1; so your not redeclaring it but using the one you declared earlier. When you originaly declare moveGuy you need to set its initial value to 0 or its initial value will be undefined and undefined plus one euqals NaN. Heres a version with the fixes… JS Bin - Collaborative JavaScript Debugging
And you seem to have removed the other error where you where using JQuery without including jquery.
Creating engaging and entertaining content for designers and developers since 1998.