Created
December 8, 2012 14:13
-
-
Save xjunior/4240397 to your computer and use it in GitHub Desktop.
LastScene
This file contains hidden or 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
var Robot = function(robot) { | |
robot.ahead(100); | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var self = ev.robot; | |
this.cloneIfPossible(self); | |
this.shootAsap(self); | |
self.turn(2); | |
self.ahead(10); | |
}; | |
Robot.prototype.cloneIfPossible(self) { | |
if (self.availableClones > 0) | |
self.clone(); | |
}; | |
Robot.prototype.shootAsap = function(self) { | |
while (self.gunCoolDownTime > 0); | |
self.fire(); | |
}; | |
Robot.prototype.pointAndShoot = function(self, target) { | |
self.rotateCannon(target.cannonAngle); | |
this.shootAsap(); | |
}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
this.pointAndShoot(ev.robot, ev.scannedRobot); | |
}; | |
Robot.prototype.onRobotCollision = function(ev) { | |
this.pointAndShoot(ev.robot, ev.collidedRobot); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment