Skip to content

Instantly share code, notes, and snippets.

@lucasaug
Created December 11, 2012 15:00
Show Gist options
  • Save lucasaug/4259141 to your computer and use it in GitHub Desktop.
Save lucasaug/4259141 to your computer and use it in GitHub Desktop.
SnakeSkin
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
this.step = 60;
this.baseRot = 70;
this.rotDir = 1;
this.shootRot = 50;
this.turnQuant = 10;
this.turnDir = 1;
this.count = 0;
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(this.step);
robot.rotateCannon(this.baseRot * this.rotDir);
if(this.count % 5 == 0){
//robot.turn(this.turnQuant * this.turnDir);
}
this.count++;
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
robot.rotateCannon(40 * this.rotDir);
this.rotDir *= -1;
};
Robot.prototype.onHitByBullet = function(ev){
var robot = ev.robot;
robot.back(100);
};
Robot.prototype.onWallCollision = function(ev){
var robot = ev.robot;
robot.turn(ev.bearing + 140);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment