-
-
Save fwitzke/4216881 to your computer and use it in GitHub Desktop.
cheater666
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 Robot = function(robot) { | |
robot.rotateCannon(-90); | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(); | |
}; | |
function isClone(robot1, robot2) { | |
return robot1.id == robot2.parentId || robot1.parentId == robot2.id; | |
} | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
var scanned = ev.scannedRobot; | |
if(!isClone(robot, scanned)) { | |
robot.fire(); | |
robot.rotateCannon(-15); | |
robot.rotateCannon(15); | |
} else { | |
} | |
}; | |
Robot.prototype.onHitByBullet = function(ev) { | |
var robot = ev.robot; | |
robot.clone(); | |
robot.ahead(60); | |
robot.back(60); | |
}; | |
Robot.prototype.onRobotCollision = function(ev) { | |
var robot = ev.robot; | |
robot.rotateCannon(90); | |
robot.back(100); | |
robot.rotateCannon(-90); | |
}; | |
Robot.prototype.onWallCollision = function(ev) { | |
var robot = ev.robot; | |
if(robot.parentId) { //clone | |
robot.turn(90-ev.bearing); | |
} else { | |
robot.turn(-90+ev.bearing); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment