Created
February 1, 2015 20:05
-
-
Save JogoShugh/f2c63e9c3b467cdcb71f to your computer and use it in GitHub Desktop.
move.js
This file contains 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
function move(spaces, direction) { | |
playerCurrent.p.direction = direction; | |
playerCurrent.p.speed = 100; | |
console.log(playerCurrent.p.x); | |
var timeOut = 317; | |
var lastStep = function() { playerCurrent.p.speed = 0; console.log(playerCurrent.p.x); }; | |
var step = function() { playerCurrent.p.speed = 100; }; | |
var runStep = function() { | |
step(); | |
spaces--; | |
if (spaces > 1) { | |
setTimeout(runStep, timeOut); | |
} | |
else { | |
setTimeout(lastStep, timeOut); | |
} | |
}; | |
runStep(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment