Skip to content

Instantly share code, notes, and snippets.

@satansfate
Created December 5, 2012 17:42
Show Gist options
  • Save satansfate/4217809 to your computer and use it in GitHub Desktop.
Save satansfate/4217809 to your computer and use it in GitHub Desktop.
SatansFate
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
var location = 0;
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if(location == 0){
robot.rotateCannon(1);
}
else {
var change = location - ev.robot.cannonRelativeAngle;
robot.rotateCannon(change);
robot.fire();
}
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
var angle = ev.robot.cannonRelativeAngle;
location = angle;
robot.fire();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment