Created
December 5, 2012 14:24
-
-
Save samelinux/4215862 to your computer and use it in GitHub Desktop.
To Delete
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
| var Robot=function(robot) | |
| { | |
| robot.clone(); | |
| }; | |
| Robot.prototype.onIdle=function(ev) | |
| { | |
| var io=ev.robot; | |
| io.ahead(10); | |
| if(io.parentId) | |
| { | |
| io.rotateCannon(10); | |
| } | |
| else | |
| { | |
| io.rotateCannon(-10); | |
| } | |
| }; | |
| Robot.prototype.onScannedRobot=function(ev) | |
| { | |
| var io=ev.robot; | |
| var nemico=ev.scannedRobot; | |
| if (io.id==nemico.parentId || io.parentId==nemico.id) | |
| { | |
| return; | |
| } | |
| // io.fire(); | |
| if(io.parentId) | |
| { | |
| io.rotateCannon(-25); | |
| } | |
| else | |
| { | |
| io.rotateCannon(25); | |
| } | |
| }; | |
| Robot.prototype.onRobotCollision=function(ev) | |
| { | |
| var io=ev.robot; | |
| var nemico=ev.collidedRobot; | |
| if (io.id==nemico.parentId || io.parentId==nemico.id) | |
| { | |
| io.turn(180); | |
| io.ahead(10); | |
| } | |
| else | |
| { | |
| io.turn(-ev.bearing); | |
| } | |
| } | |
| Robot.prototype.onWallCollision=function(ev) | |
| { | |
| var io=ev.robot; | |
| io.ignore('onRobotCollision'); | |
| io.turn(180); | |
| io.listen('onRobotCollision'); | |
| } | |
| Robot.prototype.onHitByBullet=function(ev) | |
| { | |
| var io=ev.robot; | |
| io.turn(180); | |
| o.ahead(10); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment