Skip to content

Instantly share code, notes, and snippets.

@ahpook
Created July 9, 2013 06:26
Show Gist options
  • Save ahpook/5955122 to your computer and use it in GitHub Desktop.
Save ahpook/5955122 to your computer and use it in GitHub Desktop.
Solution to http://bitsquest.bitbucket.org/index.html#4 , even though it's not necessary to use the variable (you can just go up and right till you hit the right wall, then down)
var beenTop = false;
this.on("start", function() {
this.thrusters.left(true);
});
this.on('sensor:top', function(contact) {
this.thrusters.bottom(false);
beenTop = true;
});
this.on('sensor:right', function(contact) {
if (beenTop) {
this.thrusters.top(true);
}
else {
this.thrusters.bottom(true);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment