Skip to content

Instantly share code, notes, and snippets.

@Walko
Created December 4, 2012 13:34
Show Gist options
  • Save Walko/4203927 to your computer and use it in GitHub Desktop.
Save Walko/4203927 to your computer and use it in GitHub Desktop.
Sperminator
//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(1);
robot.rotateCannon(360);
robot.ahead(1);
//robot.back(1000);
// robot.rotateCannon(360);
// robot.turn(20);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
// robot.fire(4);
// robot.rotateCannon(0,1);
// robot.fire(1);
// robot.rotateCannon(0,1);
//robot.rotateCannon(10);
// robot.turn(50);
//robot.ahead(5000);
robot.stop();
robot.fire();
robot.turn(25);
robot.ahead(50);
robot.rotateCannon(-30);
robot.fire();
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
robot.fire(5);
robot.turn(200);
robot.ahead(500); // trying to run away
// robot.clone(robot);
};
Robot.prototype.onHitByBullet = function(ev) {
var robot;
robot = ev.robot;
robot.ahead(50);
robot.turn(50 - ev.bulletBearing);
robot.back(50);
};
//Robot.prototype.onScannedRobot = function(ev) {
// var robot;
// var robot1;
//var scanned =ev.scannedRobot;
//robot = ev.robot;
//robot.fire(5);
// robot1.clone(robot);
// if(scannedRobot !== robot1.parentId && scanned.parentId !== robot1.id)
// robot1.fire(2);
//};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment