Skip to content

Instantly share code, notes, and snippets.

@zoltax
Forked from randompast/robot.js
Created December 4, 2012 16:44
Show Gist options
  • Save zoltax/4206024 to your computer and use it in GitHub Desktop.
Save zoltax/4206024 to your computer and use it in GitHub Desktop.
QR-bot-008
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
for(var i=0; i<30; i++){
robot.ahead(4);
robot.turn(4);
robot.rotateCannon(4);
}
for(var i=0; i<30; i++){
robot.back(4);
robot.turn(4);
robot.rotateCannon(4);
}
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
robot.rotateCannon(-20);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment