Created
January 5, 2014 16:31
-
-
Save dchaplinsky/8270334 to your computer and use it in GitHub Desktop.
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
| /* | |
| * This other bot is helping-- somewhat. | |
| */ | |
| var stop = function(self) { | |
| self.thrusters.top(false); | |
| self.thrusters.left(false); | |
| self.thrusters.bottom(false); | |
| self.thrusters.right(false); | |
| } | |
| this.on("start", function() { | |
| this.thrusters.bottom(true); | |
| }); | |
| this.on("sensor:top", function(foo) { | |
| if (foo) { | |
| stop(this); | |
| this.thrusters.left(true); | |
| this.radar.ping(); | |
| } | |
| }); | |
| this.on("radar:hit", function(angle, distance) { | |
| if (distance < 5) { | |
| stop(this); | |
| } else { | |
| this.thrusters.left(true); | |
| } | |
| this.radar.ping(); | |
| }); | |
| this.on("radar:miss", function(angle, distance) { | |
| this.thrusters.left(true); | |
| this.radar.ping(); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment