Skip to content

Instantly share code, notes, and snippets.

@JogoShugh
Created February 1, 2015 20:05
Show Gist options
  • Save JogoShugh/f2c63e9c3b467cdcb71f to your computer and use it in GitHub Desktop.
Save JogoShugh/f2c63e9c3b467cdcb71f to your computer and use it in GitHub Desktop.
move.js
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