Skip to content

Instantly share code, notes, and snippets.

@opiispanen
Created December 3, 2012 20:29
Show Gist options
  • Save opiispanen/4197747 to your computer and use it in GitHub Desktop.
Save opiispanen/4197747 to your computer and use it in GitHub Desktop.
GeneralPwner
//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(200);
robot.turn(180);
robot.ahead(200);
robot.turn(45);
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.turn(100);
robot.ahead(100);
robot.turn(100);
robot.ahead(300);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire(1);
robot.rotateCannon(15);
robot.fire(1);
robot.rotateCannon(-15);
};
Robot.prototype.onHitByBullet = function(ev) {
var robot;
robot = ev.robot;
robot.ahead(200);
robot.turn(90 - ev.bulletBearing);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment