Skip to content

Instantly share code, notes, and snippets.

@tarsisazevedo
Created November 30, 2012 03:46
Show Gist options
  • Save tarsisazevedo/4173665 to your computer and use it in GitHub Desktop.
Save tarsisazevedo/4173665 to your computer and use it in GitHub Desktop.
Invisible death
//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.clone();
robot.ahead(120);
robot.rotateCannon(360);
robot.back(70);
robot.rotateCannon(360);
robot.turn(360);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
var scannedRobot = ev.scannedRobot;
if (scannedRobot.parentId === robot.id) {
return;
}
robot.fire();
};
Robot.prototype.onHitByBullet = function(ev) {
var robot;
robot = ev.robot;
robot.turn(90 - ev.bulletBearing);
};
Robot.prototype.onRobotCollision = function(ev) {};
Robot.prototype.onWallCollision = function(ev) {};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment