Skip to content

Instantly share code, notes, and snippets.

@samelinux
Forked from zachiPL/robot.js
Created December 7, 2012 10:27
Show Gist options
  • Select an option

  • Save samelinux/4232357 to your computer and use it in GitHub Desktop.

Select an option

Save samelinux/4232357 to your computer and use it in GitHub Desktop.
OpenBarbarian
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
robot.rotateCannon(-90);
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(30);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
//robot.stop();
robot.fire();
robot.back(50);
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.turn(ev.bearing - 90);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment