-
-
Save shingara/4233939 to your computer and use it in GitHub Desktop.
THE 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.rotateCannon(360); | |
robot.ahead(50); | |
robot.turn(30); | |
robot.back(100); | |
robot.turn(50); | |
}; | |
// yay we see another robot! time to wreak some havoc... | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot; | |
robot = ev.robot; | |
robot.fire(10); | |
robot.turn(30); | |
robot.back(200); | |
}; | |
// this method gets called whenever we hit another robot... | |
Robot.prototype.onRobotCollision = function(ev) { | |
var robot; | |
robot = ev.robot; | |
robot.back(200); | |
robot.turn(45); | |
robot.ahead(200); | |
}; | |
// this method gets called whenever we hit a wall... | |
Robot.prototype.onWallCollision = function(ev) { | |
var robot; | |
robot = ev.robot; | |
robot.turn(45); | |
robot.back(50); | |
robot.back(50); | |
robot.turn(45); | |
}; | |
// ohhh... we were hit by another robot... | |
Robot.prototype.onHitByBullet = function(ev) { | |
var robot; | |
robot = ev.robot; | |
robot.turn(45); | |
robot.back(50); | |
robot.clone(); | |
robot.turn(ev.bearing); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment