Created
December 4, 2012 01:17
-
-
Save dakerfp/4199638 to your computer and use it in GitHub Desktop.
halfling
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
var IDLE = 0; | |
var SCANNED = 1; | |
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
this.state = IDLE; | |
}; | |
Robot.prototype.scannedState() { | |
robot.ahead(100); | |
robot.rotateCannon(-15); | |
robot.back(100); | |
robot.rotateCannon(15); | |
this.state = IDLE; | |
} | |
Robot.prototype.idleState() { | |
robot.ahead(30); | |
robot.rotateCannon(90); | |
robot.back(30); | |
robot.rotateCannon(90); | |
robot.back(30); | |
robot.rotateCannon(90); | |
robot.back(30); | |
robot.rotateCannon(90); | |
} | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
if (this.state == IDLE) | |
this.idleState(); | |
else if (this.state == SCANNED) | |
this.scannedState | |
}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
// this.state = SCANNED; | |
robot.fire(); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What about triple equality? Be careful man! JavaScript! 👍