Created
December 1, 2012 22:02
-
-
Save robertomoulin/4185450 to your computer and use it in GitHub Desktop.
Chewbacca
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.clone(); | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(40); | |
robot.rotateCannon(360);}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot, | |
scannedRobot = ev.scannedRobot, | |
friend = robot.id === scannedRobot.parentId || robot.parentId === scannedRobot.id; | |
if (!friend) { | |
robot.fire(); | |
robot.rotateCannon(-20); | |
robot.ahead(40); | |
} | |
}; | |
Robot.prototype.onWallCollision = function(ev) { | |
var robot = ev.robot; | |
robot.back(200);}; | |
Robot.prototype.onRobotCollision = function(ev) { | |
var robot = ev.robot; | |
robot.back(200); | |
robot.turn(110); | |
}; | |
Robot.prototype.onHitByBullet = function(ev) { | |
var robot; | |
robot = ev.robot; | |
robot.back(40); | |
}; | |
/// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment