Created
December 4, 2012 19:28
-
-
Save S3Mi/4207771 to your computer and use it in GitHub Desktop.
bulbator_0.5
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
| //DEPRECATED | |
| var Robot = function(robot) {}; | |
| var angle = 20; | |
| var curAngle = angle; | |
| var targetingAngle = 10; | |
| var idleCyclesWOEnemy = 0; | |
| var cycles = 0; | |
| var targetCycles = 3; | |
| var targeting = false; | |
| Robot.prototype.onIdle = function(ev) { | |
| var robot = ev.robot; | |
| if(targeting){ | |
| robot.rotateCannon(targetingAngle); | |
| cycles++; | |
| if(cycles == targetCycles){ | |
| targetingAngle = -targetingAngle; | |
| cycles = 0; | |
| } | |
| } else { | |
| robot.ahead(10); | |
| robot.rotateCannon(angle); | |
| } | |
| idleCyclesWOEnemy++; | |
| if(idleCyclesWOEnemy >= 10){ | |
| targeting = false; | |
| } | |
| }; | |
| Robot.prototype.onScannedRobot = function(ev) { | |
| var robot = ev.robot; | |
| robot.fire(); | |
| targeting = true; | |
| //cycles = 0; | |
| idleCyclesWOEnemy = 0; | |
| }; | |
| Robot.prototype.onWallCollision = function(ev) { | |
| var robot = ev.robot; | |
| robot.turn(-ev.bearing); // turn enought to be in a straight | |
| // angle with the wall. | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment