Skip to content

Instantly share code, notes, and snippets.

@andyzinsser
Created December 4, 2012 16:18
Show Gist options
  • Save andyzinsser/4205713 to your computer and use it in GitHub Desktop.
Save andyzinsser/4205713 to your computer and use it in GitHub Desktop.
Meany
//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.fire();
robot.turn(90);
robot.ahead(800);
robot.fire(5);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
for (key in robot) {
alert(key)
}
robot.fire(3);
robot.ahead(50);
robot.turn(-50);
robot.rotateCannon(50);
robot.fire(5);
};
// this method gets called whenever we hit a wall...
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.back(100);
robot.turn(90);
robot.fire();
robot.ahead(100);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment