Created
December 6, 2012 12:22
-
-
Save CarterTsai/4224081 to your computer and use it in GitHub Desktop.
CARTER's ROBOT
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 Robot(robot) {} | |
// well, we need to do something... | |
// whenever our robot is idle, this method gets called. | |
Robot.prototype.onIdle = function(ev) { | |
var robot; | |
robot = ev.robot; | |
robot.ahead(10); | |
robot.turn(5); | |
robot.ahead(20); | |
robot.turn(5); | |
robot.ahead(10); | |
robot.turn(5); | |
}; | |
// yay we see another robot! time to wreak some havoc... | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot; | |
robot = ev.robot; | |
robot.ahead(ev.scannedRobot.x); | |
robot.rotateCannon(ev.scannedRobot.cannonAngle); | |
robot.fire(1); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment