Quantcast
Channel: Keyboard handler to move a shape in response to arrow keys - Code Review Stack Exchange
Browsing all 3 articles
Browse latest View live

Answer by jfriend00 for Keyboard handler to move a shape in response to arrow...

If you move shipLeft and shipTop into an object called shipPositions rather than just top level variables, you could also use a map-driven approach like this:function anim(e) { var key = e.KeyCode ||...

View Article



Answer by jfriend00 for Keyboard handler to move a shape in response to arrow...

Basically, each branch of your if/else does the following:Update the appropriate shipXXX variable with an appropriate increment.Set the appropriate ship.style.xxx value.Call changeColor().return the...

View Article

Keyboard handler to move a shape in response to arrow keys

I finished Codeacademy and I'm looking to practice and get better at JavaScript. Is this coded correctly or should I have made a function for it somehow? The purpose of this code is to move a square...

View Article
Browsing all 3 articles
Browse latest View live




Latest Images