Skip to content

Instantly share code, notes, and snippets.

@xjunior
Created December 8, 2012 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xjunior/4240397 to your computer and use it in GitHub Desktop.
Save xjunior/4240397 to your computer and use it in GitHub Desktop.
LastScene
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