Created
December 1, 2012 02:04
-
-
Save joseleme/4180158 to your computer and use it in GitHub Desktop.
Biriba Destroyer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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(70); | |
robot.turn(40); | |
robot.rotateCannon(60); | |
var clone = robot.clone(); | |
robot.ahead(50); | |
robot.turn(40); | |
}; | |
Robot.prototype.onRobotCollision= function(ev) { | |
var robot = ev.robot; | |
robot.turn(ev.bearing); | |
robot.ahead(50); // trying to run away | |
robot.rotateCannon(60); | |
}; | |
Robot.prototype.onWallCollision = function(ev) { | |
var robot = ev.robot; | |
robot.turn(190); // turn enought to be in a straight | |
// angle with the wall. | |
robot.ahead(50); | |
robot.rotateCannon(60); | |
}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
if(ev.scannedRobot.parentId != robot.id && ev.scannedRobot.id != robot.parentId){ | |
robot.fire(); | |
} | |
robot.turn(robot.angle-ev.scannedRobot.angle); | |
robot.rotateCannon(robot.cannonAbsoluteAngle - ev.scannedRobot.angle); | |
robot.ahead(70); | |
}; | |
Robot.prototype.onHitByBullet = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(50); | |
robot.turn(ev.bearing-90); | |
robot.rotateCannon(270); // Turn to wherever the bullet was fired | |
// so we can see who shot it | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment