Skip to content

Instantly share code, notes, and snippets.

@kborchers
Created December 5, 2012 21:50
Show Gist options
  • Save kborchers/4219811 to your computer and use it in GitHub Desktop.
Save kborchers/4219811 to your computer and use it in GitHub Desktop.
AEROBOT
//FightCode can only understand your robot
//if its class is called Robot
var cloneId,
Robot = function(robot) {
var robot2 = robot.clone();
cloneId = robot2.id;
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
for(var i=1; i<=36; i++){
robot.ahead(10);
robot.rotateCannon(10);
robot.turn(10);
}
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
if(ev.scannedRobot.id != robot.parentId && ev.scannedRobot.id != cloneId)
robot.fire();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment