I am attempting to develop code where a gamer can EFFICIENTLY cross the display making use of the key-board.
This is my code:
var deltax = 0;
var deltay = 0;
var tricks = [];.
window.addEventListener(" keydown", feature( e) {
tricks[e.keyCode] = real;.
if (tricks[37]) {
deltax = deltax - 2;.
}
if (tricks[39]) {
deltax = deltax + 2;.
}
if (tricks[38]) {
deltay = deltay - 2;.
}
if (tricks[40]) {
deltay = deltay + 2;.
}
e.preventDefault();.
drawCharacter();.
} );.
window.addEventListener(" keyup", feature( e) {
tricks[e.keyCode] = incorrect;.
} );.
I was anticipating to have an efficiently computer animated activity, yet rather the block relocates 2 pixels every secondly.