Created
December 4, 2012 22:04
-
-
Save jkaflik/4209303 to your computer and use it in GitHub Desktop.
NaOkoło
This file contains hidden or 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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
}; | |
var takeDir = false | |
var haveTurn = true; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
if( takeDir ) | |
{ | |
if( haveTurn ) | |
{ | |
robot.turn(takeDir-robot.angle); | |
robot.rotateCannon(-(takeDir-robot.angle)); | |
haveTurn = false; | |
} | |
else | |
{ | |
robot.rotateCannon(-5); | |
robot.ahead(50); | |
robot.rotateCannon(5); | |
robot.back(-50); | |
} | |
} | |
else | |
{ | |
robot.rotateCannon(5); | |
} | |
}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
robot.fire(); | |
takeDir = robot.cannonAbsoluteAngle; | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment