Skip to content

Instantly share code, notes, and snippets.

@diguinhorocks
Created December 5, 2012 23:57
Show Gist options
  • Save diguinhorocks/4220673 to your computer and use it in GitHub Desktop.
Save diguinhorocks/4220673 to your computer and use it in GitHub Desktop.

Revisions

  1. diguinhorocks revised this gist Dec 6, 2012. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ Robot.prototype.onIdle = function(ev) {
    robot.rotateCannon(-20);
    robot.turn(100);
    robot.ahead(300);
    robot.rotateCannon(-90);
    robot.rotateCannon(90);


    };
    @@ -26,7 +26,8 @@ Robot.prototype.onScannedRobot = function(ev) {
    };

    Robot.prototype.onRobotCollision = function(ev) {
    ev.robot.fire(2);
    ev.robot.rotateCannon(20);
    ev.robot.fire(2);
    };

    Robot.prototype.onHitByBullet = function(ev) {
  2. diguinhorocks revised this gist Dec 6, 2012. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -8,10 +8,11 @@ var Robot = function(robot) {
    Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.ahead(300);
    robot.rotateCannon(20);
    robot.rotateCannon(-20);
    robot.turn(100);
    robot.ahead(300);
    robot.rotateCannon(90);
    robot.rotateCannon(-90);


    };

  3. diguinhorocks revised this gist Dec 6, 2012. 1 changed file with 5 additions and 3 deletions.
    8 changes: 5 additions & 3 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -8,9 +8,9 @@ var Robot = function(robot) {
    Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.ahead(300);
    robot.rotateCannon(20);
    robot.turn(100);
    robot.rotateCannon(90);
    robot.turn(20);
    robot.ahead(300);
    robot.rotateCannon(90);

    };
    @@ -19,6 +19,8 @@ Robot.prototype.onScannedRobot = function(ev) {
    var robot = ev.robot;

    robot.fire(2);
    robot.fire(2);
    robot.fire(2);

    };

    @@ -29,7 +31,7 @@ Robot.prototype.onRobotCollision = function(ev) {
    Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
    robot.turn(90 - ev.bulletBearing);
    robot.turn(ev.bulletBearing);
    };

    Robot.prototype.onWallCollision = function(ev) {
  4. diguinhorocks created this gist Dec 5, 2012.
    40 changes: 40 additions & 0 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@

    //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(300);
    robot.turn(100);
    robot.rotateCannon(90);
    robot.turn(20);
    robot.rotateCannon(90);

    };

    Robot.prototype.onScannedRobot = function(ev) {
    var robot = ev.robot;

    robot.fire(2);

    };

    Robot.prototype.onRobotCollision = function(ev) {
    ev.robot.fire(2);
    };

    Robot.prototype.onHitByBullet = function(ev) {
    var robot;
    robot = ev.robot;
    robot.turn(90 - ev.bulletBearing);
    };

    Robot.prototype.onWallCollision = function(ev) {
    var robot = ev.robot;
    robot.turn(ev.bearing); // turn enought to be in a straight
    // angle with the wall.
    };