Reputation: 277
I'm toying with simple game creation using the canvas, and I've created a simple setup on JSBin. It uses the arrow keys to move the player around and collect gold that respawns thereafter. Everything works great.
EXCEPT. When I initially run the code, the player and gold squares flash on the canvas, then disappear. They will only reappear after all four arrow keys have been pressed in turn. I have determined that the issue is in my update function where I'm checking the down variables, but I'm not sure what I should be doing differently. I welcome your insight and wisdom.
Upvotes: 0
Views: 45
Reputation: 105035
You've forgotten to declare the leftDown,upDown,downDown,rightDown
variables so your update() fails when trying to use rightdown
Fix: declare those variables:
var leftDown,upDown,downDown,rightDown;
Upvotes: 1