Skip to content

Instantly share code, notes, and snippets.

@JohanLarsson
Created February 6, 2013 18:56
Show Gist options
  • Save JohanLarsson/4724855 to your computer and use it in GitHub Desktop.
Save JohanLarsson/4724855 to your computer and use it in GitHub Desktop.
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
this.scanDir=1;
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.fire();
robot.ahead(1);
robot.fire();
//robot.rotateCannon(this.scanDir* 5-5);
robot.fire();
robot.turn(1)
robot.fire();
//robot.back(100);
//robot.rotateCannon(360);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
console.log("Scanned one");
robot.fire();
robot.rotateCannon(this.scanDir* 5);
this.scanDir=-1*this.scanDir;
robot.fire();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment