Skip to content

Instantly share code, notes, and snippets.

@samelinux
Created December 5, 2012 14:24
Show Gist options
  • Select an option

  • Save samelinux/4215862 to your computer and use it in GitHub Desktop.

Select an option

Save samelinux/4215862 to your computer and use it in GitHub Desktop.

Revisions

  1. samelinux revised this gist Dec 7, 2012. 1 changed file with 0 additions and 67 deletions.
    67 changes: 0 additions & 67 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -1,67 +0,0 @@
    var Robot=function(robot)
    {
    robot.clone();
    };

    Robot.prototype.onIdle=function(ev)
    {
    var io=ev.robot;
    io.ahead(10);
    if(io.parentId)
    {
    io.rotateCannon(10);
    }
    else
    {
    io.rotateCannon(-10);
    }
    };

    Robot.prototype.onScannedRobot=function(ev)
    {
    var io=ev.robot;
    var nemico=ev.scannedRobot;
    if (io.id==nemico.parentId || io.parentId==nemico.id)
    {
    return;
    }
    io.fire();
    if(io.parentId)
    {
    io.rotateCannon(-25);
    }
    else
    {
    io.rotateCannon(25);
    }
    };

    Robot.prototype.onRobotCollision=function(ev)
    {
    var io=ev.robot;
    var nemico=ev.collidedRobot;
    if (io.id==nemico.parentId || io.parentId==nemico.id)
    {
    io.turn(180);
    io.ahead(10);
    }
    else
    {
    io.turn(-ev.bearing);
    }
    }

    Robot.prototype.onWallCollision=function(ev)
    {
    var io=ev.robot;
    io.ignore('onRobotCollision');
    io.turn(180);
    io.listen('onRobotCollision');
    }

    Robot.prototype.onHitByBullet=function(ev)
    {
    var io=ev.robot;
    io.turn(180);
    io.ahead(10);
    }
  2. samelinux revised this gist Dec 5, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion robot.js
    Original file line number Diff line number Diff line change
    @@ -25,7 +25,7 @@ Robot.prototype.onScannedRobot=function(ev)
    {
    return;
    }
    // io.fire();
    io.fire();
    if(io.parentId)
    {
    io.rotateCannon(-25);
  3. samelinux revised this gist Dec 5, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion robot.js
    Original file line number Diff line number Diff line change
    @@ -63,5 +63,5 @@ Robot.prototype.onHitByBullet=function(ev)
    {
    var io=ev.robot;
    io.turn(180);
    o.ahead(10);
    io.ahead(10);
    }
  4. samelinux revised this gist Dec 5, 2012. 1 changed file with 60 additions and 15 deletions.
    75 changes: 60 additions & 15 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,67 @@

    //FightCode can only understand your robot
    //if its class is called Robot
    var Robot = function(robot) {

    var Robot=function(robot)
    {
    robot.clone();
    };

    Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.ahead(100);
    robot.rotateCannon(360);
    robot.back(100);
    robot.rotateCannon(360);
    Robot.prototype.onIdle=function(ev)
    {
    var io=ev.robot;
    io.ahead(10);
    if(io.parentId)
    {
    io.rotateCannon(10);
    }
    else
    {
    io.rotateCannon(-10);
    }
    };

    Robot.prototype.onScannedRobot=function(ev)
    {
    var io=ev.robot;
    var nemico=ev.scannedRobot;
    if (io.id==nemico.parentId || io.parentId==nemico.id)
    {
    return;
    }
    // io.fire();
    if(io.parentId)
    {
    io.rotateCannon(-25);
    }
    else
    {
    io.rotateCannon(25);
    }
    };

    Robot.prototype.onScannedRobot = function(ev) {
    var robot = ev.robot;
    robot.fire();
    Robot.prototype.onRobotCollision=function(ev)
    {
    var io=ev.robot;
    var nemico=ev.collidedRobot;
    if (io.id==nemico.parentId || io.parentId==nemico.id)
    {
    io.turn(180);
    io.ahead(10);
    }
    else
    {
    io.turn(-ev.bearing);
    }
    }

    };
    Robot.prototype.onWallCollision=function(ev)
    {
    var io=ev.robot;
    io.ignore('onRobotCollision');
    io.turn(180);
    io.listen('onRobotCollision');
    }

    Robot.prototype.onHitByBullet=function(ev)
    {
    var io=ev.robot;
    io.turn(180);
    o.ahead(10);
    }
  5. samelinux created this gist Dec 5, 2012.
    22 changes: 22 additions & 0 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@

    //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(100);
    robot.rotateCannon(360);
    robot.back(100);
    robot.rotateCannon(360);

    };

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

    };