Skip to content

Instantly share code, notes, and snippets.

@pawel-dubiel
Created December 4, 2012 19:31
Show Gist options
  • Save pawel-dubiel/4207793 to your computer and use it in GitHub Desktop.
Save pawel-dubiel/4207793 to your computer and use it in GitHub Desktop.
basicus
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
var save_gun_positon = '';
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
for ( i =0; i< 50;i++) {
robot.ahead(100);
robot.rotateCannon(180);
}
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.back(100);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
};
Robot.prototype.onHitByBullet = function(ev) {
var robot;
robot = ev.robot;
robot.turn(90 - ev.bulletBearing);
robot.fire();
robot.back(40);
robot.ahead(40);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment