Skip to content

Instantly share code, notes, and snippets.

@Odaeus
Created December 11, 2012 21:39
Show Gist options
  • Save Odaeus/4262397 to your computer and use it in GitHub Desktop.
Save Odaeus/4262397 to your computer and use it in GitHub Desktop.
Alpha Charlie
//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 < 3; i++) {
robot.rotateCannon(90);
robot.ahead(60);
}
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
setTimeout(function(robot) { console.log(robot); robot.fire(); },
robot.gunCoolDownTime,
robot);
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.back(10);
robot.turn(120);
robot.ahead(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment