Skip to content

Instantly share code, notes, and snippets.

@PierrickP
Created December 6, 2012 17:07
Show Gist options
  • Save PierrickP/4226147 to your computer and use it in GitHub Desktop.
Save PierrickP/4226147 to your computer and use it in GitHub Desktop.
Find&shoot
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
this.find = false;
this.shot = 0;
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if (!Robot.find || Robot.shot == 3) {
robot.rotateCannon(1);
Robot.shot = 0;
} else {
robot.fire();
}
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
Robot.find = true;
Robot.shot++;
robot.fire();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment