Created
December 4, 2012 21:33
-
-
Save renatodossantosleal/4208950 to your computer and use it in GitHub Desktop.
Catentulho
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
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) {}; | |
var locked = false; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
if(!locked){ | |
robot.turn(20); | |
robot.ahead(100); | |
robot.rotateCannon(360); | |
}else{ | |
robot.turn(10); | |
robot.turn(10); | |
robot.fire(); | |
locked = false; | |
} | |
if(robot.life == 10){ | |
robot.clone() | |
} | |
}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
var enemy = ev.scannedRobot; | |
if(enemy.parentId != robot.id){ | |
robot.log(); | |
robot.fire(); | |
locked = true; | |
robot.rotateCannon(180); | |
} | |
}; | |
// this method gets called whenever we hit another robot... | |
Robot.prototype.onRobotCollision = function(ev) { | |
var robot = ev.robot; | |
robot.turn(130); | |
robot.ahead(10); | |
}; | |
// this method gets called whenever we hit a wall... | |
Robot.prototype.onWallCollision = function(ev) { | |
var robot = ev.robot; | |
robot.turn(10); | |
robot.ahead(10); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment