Created
December 19, 2012 13:41
-
-
Save kdungs/4336724 to your computer and use it in GitHub Desktop.
Gauß 2.0
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) { | |
}; | |
var found = false; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
if (!found) { | |
robot.rotateCannon(1); | |
robot.ahead(1); | |
robot.turn(1); | |
} | |
}; | |
Robot.prototype.onRobotCollision = function(ev) { | |
var robot = ev.robot; | |
if (robot.life > ev.collideRobot.life) { | |
robot.rotateCannon(ev.bearing); // Attack! | |
} else { | |
robot.ahead(20); // Run! | |
} | |
} | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
found = true; | |
robot.fire().notify(function() { | |
found = false; | |
}); | |
}; | |
Robot.prototype.onHitByBullet = function(ev) { | |
var robot = ev.robot; | |
robot.turn(ev.bearing + 20); | |
robot.ahead(20); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment