Skip to content

Instantly share code, notes, and snippets.

@meal
Created December 4, 2012 13:17
Show Gist options
  • Save meal/4203773 to your computer and use it in GitHub Desktop.
Save meal/4203773 to your computer and use it in GitHub Desktop.
Robotron
//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;
robot.ahead(50);
robot.turn(45);
robot.turn(-20);
robot.back(20);
robot.turn(50);
robot.fire();
robot.ahead(15);
robot.fire();
robot.rotateCannon(180);
robot.fire();
robot.rotateCannon(180);
robot.fire();
robot.rotateCannon(180);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
robot.rotateCannon(-1);
robot.fire();
robot.rotateCannon(1);
robot.fire();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment