Skip to content

Instantly share code, notes, and snippets.

@samelinux
Created December 7, 2012 17:08
Show Gist options
  • Select an option

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

Select an option

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

Revisions

  1. samelinux revised this gist Dec 8, 2012. No changes.
  2. samelinux revised this gist Dec 8, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion robot.js
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,9 @@
    var Robot = function(robot) {
    robot.rotateCannon(180);
    };

    Robot.prototype.onIdle = function(ev) {
    ev.robot.ahead(30);
    ev.robot.back(30);
    };

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

    var Robot = function(robot) {
    fired=false;
    };

    Robot.prototype.onIdle = function(ev) {
  4. samelinux created this gist Dec 7, 2012.
    21 changes: 21 additions & 0 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    var fired;

    var Robot = function(robot) {
    fired=false;
    };

    Robot.prototype.onIdle = function(ev) {
    ev.robot.ahead(30);
    };

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

    Robot.prototype.onWallCollision = function(ev) {
    ev.robot.ignore("onRobotCollision");
    ev.robot.ignore("onScannedRobot");
    ev.robot.turn(ev.bearing - 90);
    ev.robot.listen("onScannedRobot");
    ev.robot.listen("onRobotCollision");
    };