Skip to content

Instantly share code, notes, and snippets.

@MauMaGau
Created December 4, 2012 14:44
Show Gist options
  • Save MauMaGau/4204667 to your computer and use it in GitHub Desktop.
Save MauMaGau/4204667 to your computer and use it in GitHub Desktop.
MauMaGau
//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.ahead(50);
robot.rotateCannon(60);
robot.ahead(20);
//bot.back(100);
//bot.rotateCannon(360);
};
Robot.prototype.onWallCollision = function(ev) {
var robot;
robot = ev.robot;
robot.turn(90)
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
robot.rotateCannon(-40);
robot.turn(ev.bearing - 10)
robot.ahead(10)
};
Robot.prototype.onHitByBullet = function(ev) {
var robot = ev.robot;
robot.turn(50); // Turn to wherever the bullet was fired
// so we can see who shot it
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
robot.turn(20);
robot.ahead(100); // trying to run away
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment