Skip to content

Instantly share code, notes, and snippets.

@ksipe
Created December 4, 2012 15:40
Show Gist options
  • Save ksipe/4205272 to your computer and use it in GitHub Desktop.
Save ksipe/4205272 to your computer and use it in GitHub Desktop.
Xipe
//FightCode can only understand your robot
//if its class is called Robot
var i = 0;
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);
robot.turn(-20);
robot.rotateCannon(30);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
var scan = ev.scannedRobot;
if(scan.parentId == null) {
for(var i=0; i<5; i++) {
robot.fire();
var j=robot.gunCoolDownTime;
while(j>0){
j=robot.gunCoolDownTime;
robot.ahead(1);
robot.back(1);
}
}
}
robot.rotateCannon(-10);
//robot.clone();
};
Robot.prototype.onHitByBullet = function(ev) {
var robot = ev.robot;
robot.turn(90);
robot.ahead(200);
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.turn(90);
robot.back(100);
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
robot.turn(30);
robot.back(100);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment