Skip to content

Instantly share code, notes, and snippets.

@CarterTsai
Created December 6, 2012 12:22
Show Gist options
  • Save CarterTsai/4224081 to your computer and use it in GitHub Desktop.
Save CarterTsai/4224081 to your computer and use it in GitHub Desktop.
CARTER's ROBOT
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