Skip to content

Instantly share code, notes, and snippets.

@samshull
Created December 3, 2012 17:01
Show Gist options
  • Save samshull/4196340 to your computer and use it in GitHub Desktop.
Save samshull/4196340 to your computer and use it in GitHub Desktop.
destroyer of worlds
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot;
robot = ev.robot;
robot.rotateCannon(360);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
console.log(ev.scannedRobot.position);
robot.fire();
robot.turn(ev.scannedRobot.angle);
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
console.log(ev.bearing);
robot.rotateCannon(ev.bearing);
robot.fire();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment