-
-
Save mdonahoo/4209576 to your computer and use it in GitHub Desktop.
RoboTosco
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) { | |
robot.clone(); | |
}; | |
var girar = 1; | |
var count = 0; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
if(girar == 1){ | |
robot.rotateCannon(90); | |
robot.turn(120); | |
girar = 0; | |
}else{ | |
robot.ahead(5); | |
robot.turn(2); | |
robot.rotateCannon(3); | |
count += 1; | |
if(count == 90){ | |
count = 0; | |
girar = 1; | |
} | |
} | |
}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
if(!(ev.scannedRobot.parentId == robot.id) && !(ev.scannedRobot.id == robot.parentId)){ | |
robot.fire(); | |
robot.gunCoolDownTime = 0; | |
robot.rotateCannon(-25); | |
} | |
}; | |
Robot.prototype.onWallCollision = function(ev) { | |
robot.back(30); | |
}; | |
Robot.prototype.onHitByBullet = function(ev) { | |
var robot = ev.robot; | |
robot.turn(15); | |
robot.ahead(90); | |
robot.rotateCannon(ev.bearing); // Turn to wherever the bullet was fired | |
// so we can see who shot it | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment