Created
December 7, 2012 00:45
-
-
Save dlion/4229792 to your computer and use it in GitHub Desktop.
Smagen
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
| //FightCode can only understand your robot | |
| //if its class is called Robot | |
| var Robot = function(robot) { | |
| }; | |
| Robot.prototype.onIdle = function(ev) { | |
| var robot = ev.robot; | |
| robot.rotateCannon(360); | |
| }; | |
| Robot.prototype.onScannedRobot = function(ev) { | |
| var robot = ev.robot; | |
| var enemy = ev.scannedRobot; | |
| robot.fire(1); | |
| }; | |
| Robot.prototype.onRobotCollision = function(ev) { | |
| var robot = ev.robot; | |
| // trying to run away | |
| var enemy = ev.collidedRobot; | |
| robot.rotateCannon(enemy.angle); | |
| robot.back(100); | |
| }; | |
| Robot.prototype.onHitByBullet = function(ev) { | |
| var robot; | |
| robot = ev.robot; | |
| robot.turn(90 - ev.bulletBearing); | |
| }; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It sucks!