Skip to content

Instantly share code, notes, and snippets.

@beckyconning
Created April 16, 2014 16:02
Show Gist options
  • Save beckyconning/10899235 to your computer and use it in GitHub Desktop.
Save beckyconning/10899235 to your computer and use it in GitHub Desktop.
if (!me.stepping) {
if (me.canMove('right')) {
me.move('right');
}
else if (me.canMove('down')) {
me.move('down')
}
else if (me.canMove('left')) {
me.stepping = true;
me.stepIndex = 0;
me.move('left');
}
}
if (me.stepping) {
if (me.stepIndex % 2 != 0 && me.canMove('right')) {
me.stepIndex = 0;
me.stepping = false;
me.stepDirection = '';
}
else if (me.stepIndex == 0) {
if (me.canMove('up')) {
me.steppingDirection = 'up';
}
else if (me.canMove('down')) {
me.steppingDirection = 'down';
}
me.move(me.steppingDirection);
}
else {
if (me.canMove(me.steppingDirection)) {
me.move(me.steppingDirection);
}
else {
me.move('left');
}
}
me.stepIndex = me.stepIndex + 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment