Skip to content

Instantly share code, notes, and snippets.

@diguinhorocks
Created December 5, 2012 23:57
Show Gist options
  • Save diguinhorocks/4220673 to your computer and use it in GitHub Desktop.
Save diguinhorocks/4220673 to your computer and use it in GitHub Desktop.
r'santiago
//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(300);
robot.rotateCannon(-20);
robot.turn(100);
robot.ahead(300);
robot.rotateCannon(90);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire(2);
robot.fire(2);
robot.fire(2);
};
Robot.prototype.onRobotCollision = function(ev) {
ev.robot.rotateCannon(20);
ev.robot.fire(2);
};
Robot.prototype.onHitByBullet = function(ev) {
var robot;
robot = ev.robot;
robot.turn(ev.bulletBearing);
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.turn(ev.bearing); // turn enought to be in a straight
// angle with the wall.
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment