Skip to content

Instantly share code, notes, and snippets.

@willybahuaud
Created December 5, 2012 16:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save willybahuaud/4216890 to your computer and use it in GitHub Desktop.
Save willybahuaud/4216890 to your computer and use it in GitHub Desktop.
Willy Wonka
//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;
robot.ahead(200);
robot.rotateCannon(360);
robot.back(50);
robot.turn(70);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot;
var o;
robot = ev.robot;
o = ev.scannedRobot;
if(o.parentId == (robot.id||robot.id)){
robot.turn(50);
}else{
robot.turn(o.angle);
robot.rotateCannon(-(o.angle));
robot.fire(1000);
robot.ahead(10);
robot.fire(1000);
robot.ahead(10);
robot.fire(1000);
robot.ahead(10);
robot.fire(1000);
robot.ahead(10);
robot.fire(1000);
robot.back(100);
var clone = robot.clone();
}
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.turn(ev.bearing+50);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment