Created
December 6, 2012 18:18
-
-
Save hery84/4226733 to your computer and use it in GitHub Desktop.
OverKill
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(-30); | |
var rndAhead=Math.floor((Math.random()*250)+100); | |
robot.ahead(rndAhead); | |
}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
robot.fire(); | |
var rndBack=Math.floor((Math.random()*250)+50); | |
robot.back(rndBack); | |
}; | |
Robot.prototype.onRobotCollision = function(ev) { | |
var robot = ev.robot; | |
robot.stop(); | |
robot.fire(5); | |
robot.rotateCannon(-5); // trying to run away | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment