Created
December 5, 2012 05:21
-
-
Save bgun/4212586 to your computer and use it in GitHub Desktop.
Wallflower
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
// 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