Created
June 6, 2017 02:07
-
-
Save snggeng/af456565e77c24fa0974f98fd6a27e51 to your computer and use it in GitHub Desktop.
Move function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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