Skip to content

Instantly share code, notes, and snippets.

@snggeng
Created June 6, 2017 02:07
Show Gist options
  • Save snggeng/af456565e77c24fa0974f98fd6a27e51 to your computer and use it in GitHub Desktop.
Save snggeng/af456565e77c24fa0974f98fd6a27e51 to your computer and use it in GitHub Desktop.
Move function
// Move the ball around manually
function move(interactions){
if(interactions.up){
playerElement.style.top = parseInt(playerElement.style.top)-8+"px";
}
if(interactions.down){
playerElement.style.top = parseInt(playerElement.style.top)+8+"px";
}
if(interactions.left){
playerElement.style.left = parseInt(playerElement.style.left)-8+"px";
}
if(interactions.right){
playerElement.style.left = parseInt(playerElement.style.left)+8+"px";
}
if(settings.walls){ // if walls setting is true, player cannot move out of window
wall();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment