Skip to content

Instantly share code, notes, and snippets.

@writingdeveloper
Created November 20, 2017 07:10
Show Gist options
  • Save writingdeveloper/4ae12dc2d231058cae595d3839521ad4 to your computer and use it in GitHub Desktop.
Save writingdeveloper/4ae12dc2d231058cae595d3839521ad4 to your computer and use it in GitHub Desktop.
// KeyPress Settings
Player.prototype.handleInput = function(keyPress) {
if (keyPress == 'left') {
player.x -= player.speed;
}
if (keyPress == 'up') {
player.y -= player.speed - 20;
}
if (keyPress == 'right') {
player.x += player.speed;
}
if (keyPress == 'down') {
player.y += player.speed - 20;
}
console.log('keyPress is: ' + keyPress);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment