Skip to content

Instantly share code, notes, and snippets.

@bgun
Created December 5, 2012 05:21
Show Gist options
  • Save bgun/4212586 to your computer and use it in GitHub Desktop.
Save bgun/4212586 to your computer and use it in GitHub Desktop.
Wallflower
// Wallflower - a FightCodeGame.com robot by bgun
var Robot = function(robot) {
this.wallHugging = false;
this.gottaMove = false;
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if(!this.wallHugging) {
robot.ahead(1000);
} else {
robot.rotateCannon(80);
robot.rotateCannon(-80);
}
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
};
Robot.prototype.onHitByBullet = function(ev) {
robot.ahead(1000);
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
this.wallHugging = true;
robot.turn(ev.bearing+90);
robot.ahead(1000);
robot.turn(90);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment