Skip to content

Instantly share code, notes, and snippets.

@mariuszklinger
Created December 9, 2012 12:24
Show Gist options
  • Save mariuszklinger/4244645 to your computer and use it in GitHub Desktop.
Save mariuszklinger/4244645 to your computer and use it in GitHub Desktop.

Revisions

  1. mariuszklinger revised this gist Dec 11, 2012. 1 changed file with 20 additions and 20 deletions.
    40 changes: 20 additions & 20 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -9,39 +9,39 @@ Robot.prototype.onIdle = function(ev) {
    robot.ahead(this.speed);

    if(!this.fire){
    robot.rotateCannon(180);
    robot.rotateCannon(180);
    }
    };

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

    if(this.isEnemy(ev)){
    robot.fire();
    robot.fire();
    robot.rotateCannon(20);
    robot.fire();
    robot.fire();
    robot.rotateCannon(-20);
    robot.fire();
    robot.fire();
    robot.ahead(this.speed);
    //this.fire = true;
    }
    if(this.isEnemy(ev)){
    robot.fire();
    robot.fire();
    robot.rotateCannon(20);
    robot.fire();
    robot.fire();
    robot.rotateCannon(-20);
    robot.fire();
    robot.fire();
    robot.ahead(this.speed);
    //this.fire = true;
    }

    };

    Robot.prototype.onWallCollision = function(ev) {

    ev.robot.turn(ev.bearing + 90);
    ev.robot.back(this.speed);
    ev.robot.turn(ev.bearing + 90);
    ev.robot.back(this.speed);
    };

    Robot.prototype.isEnemy = function(ev){
    var me = ev.robot;
    var stranger = ev.scannedRobot;
    return (me.id != stranger.parentId) && (me.parentId != stranger.id);
    var me = ev.robot;
    var stranger = ev.scannedRobot;
    return (me.id != stranger.parentId) && (me.parentId != stranger.id);
    }

    Robot.prototype.onRobotCollision = function(ev) {
  2. mariuszklinger revised this gist Dec 11, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -20,10 +20,10 @@ Robot.prototype.onScannedRobot = function(ev) {
    if(this.isEnemy(ev)){
    robot.fire();
    robot.fire();
    robot.turn(20);
    robot.rotateCannon(20);
    robot.fire();
    robot.fire();
    robot.turn(-20);
    robot.rotateCannon(-20);
    robot.fire();
    robot.fire();
    robot.ahead(this.speed);
  3. mariuszklinger revised this gist Dec 11, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -56,7 +56,7 @@ Robot.prototype.onRobotCollision = function(ev) {

    Robot.prototype.onHitByBullet = function(ev) {
    var robot = ev.robot;
    robot.turn(ev.bearing);
    robot.fire();
    robot.turn(90);
    robot.ahead(50);
    };

  4. mariuszklinger revised this gist Dec 11, 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
    @@ -47,7 +47,7 @@ Robot.prototype.isEnemy = function(ev){
    Robot.prototype.onRobotCollision = function(ev) {
    ev.robot.turn(ev.bearing + 90);
    if(ev.myFault){
    ev.robot.back(20);
    ev.robot.back(20);
    }
    else{
    ev.robot.back(20);
  5. mariuszklinger revised this gist Dec 11, 2012. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -6,8 +6,7 @@ Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.clone();

    var s = this.speed;
    robot.ahead(s);
    robot.ahead(this.speed);

    if(!this.fire){
    robot.rotateCannon(180);
  6. mariuszklinger revised this gist Dec 11, 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
    @@ -10,7 +10,7 @@ Robot.prototype.onIdle = function(ev) {
    robot.ahead(s);

    if(!this.fire){
    robot.rotateCannon(180);
    robot.rotateCannon(180);
    }
    };

  7. mariuszklinger revised this gist Dec 11, 2012. 1 changed file with 7 additions and 5 deletions.
    12 changes: 7 additions & 5 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -46,16 +46,18 @@ Robot.prototype.isEnemy = function(ev){
    }

    Robot.prototype.onRobotCollision = function(ev) {
    ev.robot.turn(ev.bearing + 90);
    if(ev.myFault){
    ev.robot.back(20);
    }else{
    ev.robot.turn(ev.bearing + 90);
    if(ev.myFault){
    ev.robot.back(20);
    }
    else{
    ev.robot.back(20);
    }
    };

    Robot.prototype.onHitByBullet = function(ev) {
    var robot = ev.robot;
    robot.turn(ev.bearing);
    robot.turn(ev.bearing);
    robot.fire();
    };

  8. mariuszklinger revised this gist Dec 11, 2012. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -54,8 +54,8 @@ Robot.prototype.onRobotCollision = function(ev) {
    }
    };

    Robot.prototype.onHitByBullet = function(ev){
    var me = ev.robot;
    me.ahead(100);
    }
    Robot.prototype.onHitByBullet = function(ev) {
    var robot = ev.robot;
    robot.turn(ev.bearing);
    };

  9. mariuszklinger revised this gist Dec 11, 2012. No changes.
  10. mariuszklinger revised this gist Dec 11, 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
    @@ -27,7 +27,7 @@ Robot.prototype.onScannedRobot = function(ev) {
    robot.turn(-20);
    robot.fire();
    robot.fire();
    robot.back(this.speed);
    robot.ahead(this.speed);
    //this.fire = true;
    }

  11. mariuszklinger revised this gist Dec 11, 2012. No changes.
  12. mariuszklinger revised this gist Dec 11, 2012. 1 changed file with 0 additions and 4 deletions.
    4 changes: 0 additions & 4 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -7,10 +7,6 @@ Robot.prototype.onIdle = function(ev) {
    robot.clone();

    var s = this.speed;
    if(robot.life < 30){
    this.speed = 60;
    }

    robot.ahead(s);

    if(!this.fire){
  13. mariuszklinger revised this gist Dec 11, 2012. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,3 @@

    //FightCode can only understand your robot
    //if its class is called Robot
    var Robot = function(robot) {
    this.speed = 30;
    };
    @@ -34,6 +31,7 @@ Robot.prototype.onScannedRobot = function(ev) {
    robot.turn(-20);
    robot.fire();
    robot.fire();
    robot.back(this.speed);
    //this.fire = true;
    }

  14. mariuszklinger revised this gist Dec 11, 2012. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion robot.js
    Original file line number Diff line number Diff line change
    @@ -8,7 +8,6 @@ var Robot = function(robot) {
    Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.clone();


    var s = this.speed;
    if(robot.life < 30){
  15. mariuszklinger revised this gist Dec 11, 2012. No changes.
  16. mariuszklinger revised this gist Dec 11, 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
    @@ -18,7 +18,7 @@ Robot.prototype.onIdle = function(ev) {
    robot.ahead(s);

    if(!this.fire){
    robot.rotateCannon(20);
    robot.rotateCannon(180);
    }
    };

  17. mariuszklinger revised this gist Dec 11, 2012. No changes.
  18. mariuszklinger revised this gist Dec 11, 2012. 1 changed file with 6 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ var Robot = function(robot) {

    Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    //robot.clone();
    robot.clone();


    var s = this.speed;
    @@ -54,7 +54,11 @@ Robot.prototype.isEnemy = function(ev){

    Robot.prototype.onRobotCollision = function(ev) {
    ev.robot.turn(ev.bearing + 90);
    ev.robot.ahead(100);
    if(ev.myFault){
    ev.robot.back(20);
    }else{
    ev.robot.back(20);
    }
    };

    Robot.prototype.onHitByBullet = function(ev){
  19. mariuszklinger revised this gist Dec 11, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ var Robot = function(robot) {

    Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.clone();
    //robot.clone();


    var s = this.speed;
    @@ -27,14 +27,14 @@ Robot.prototype.onScannedRobot = function(ev) {
    var stranger = ev.scannedRobot;

    if(this.isEnemy(ev)){
    robot.fire();
    robot.fire();
    robot.turn(20);
    robot.fire();
    robot.fire();
    robot.turn(-20);
    robot.fire();
    robot.fire();
    robot.turn(20);
    //this.fire = true;
    }

  20. mariuszklinger revised this gist Dec 11, 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
    @@ -7,7 +7,7 @@ var Robot = function(robot) {

    Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    //robot.clone();
    robot.clone();


    var s = this.speed;
  21. mariuszklinger revised this gist Dec 11, 2012. No changes.
  22. mariuszklinger revised this gist Dec 11, 2012. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -34,6 +34,7 @@ Robot.prototype.onScannedRobot = function(ev) {
    robot.turn(-20);
    robot.fire();
    robot.fire();
    robot.turn(20);
    //this.fire = true;
    }

  23. mariuszklinger revised this gist Dec 11, 2012. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -28,8 +28,10 @@ Robot.prototype.onScannedRobot = function(ev) {

    if(this.isEnemy(ev)){
    robot.fire();
    //robot.turn(stranger.angle);
    robot.ahead(this.speed);
    robot.turn(20);
    robot.fire();
    robot.fire();
    robot.turn(-20);
    robot.fire();
    robot.fire();
    //this.fire = true;
  24. mariuszklinger revised this gist Dec 10, 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
    @@ -7,7 +7,7 @@ var Robot = function(robot) {

    Robot.prototype.onIdle = function(ev) {
    var robot = ev.robot;
    robot.clone();
    //robot.clone();


    var s = this.speed;
  25. mariuszklinger revised this gist Dec 9, 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
    @@ -14,10 +14,11 @@ Robot.prototype.onIdle = function(ev) {
    if(robot.life < 30){
    this.speed = 60;
    }

    robot.ahead(s);

    if(!this.fire){
    robot.rotateCannon(360);
    robot.rotateCannon(20);
    }
    };

  26. mariuszklinger revised this gist Dec 9, 2012. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,8 @@ Robot.prototype.onScannedRobot = function(ev) {
    robot.fire();
    //robot.turn(stranger.angle);
    robot.ahead(this.speed);
    robot.fire();
    robot.fire();
    //this.fire = true;
    }

    @@ -51,3 +53,8 @@ Robot.prototype.onRobotCollision = function(ev) {
    ev.robot.ahead(100);
    };

    Robot.prototype.onHitByBullet = function(ev){
    var me = ev.robot;
    me.ahead(100);
    }

  27. mariuszklinger revised this gist Dec 9, 2012. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion robot.js
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,10 @@ Robot.prototype.onIdle = function(ev) {
    this.speed = 60;
    }
    robot.ahead(s);
    robot.rotateCannon(360);

    if(!this.fire){
    robot.rotateCannon(360);
    }
    };

    Robot.prototype.onScannedRobot = function(ev) {
    @@ -26,6 +29,7 @@ Robot.prototype.onScannedRobot = function(ev) {
    robot.fire();
    //robot.turn(stranger.angle);
    robot.ahead(this.speed);
    //this.fire = true;
    }

    };
  28. mariuszklinger revised this gist Dec 9, 2012. No changes.
  29. mariuszklinger revised this gist Dec 9, 2012. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions robot.js
    Original file line number Diff line number Diff line change
    @@ -11,9 +11,9 @@ Robot.prototype.onIdle = function(ev) {


    var s = this.speed;
    if(robot.life < 30){
    this.speed = 60;
    }
    if(robot.life < 30){
    this.speed = 60;
    }
    robot.ahead(s);
    robot.rotateCannon(360);
    };
    @@ -44,5 +44,6 @@ Robot.prototype.isEnemy = function(ev){

    Robot.prototype.onRobotCollision = function(ev) {
    ev.robot.turn(ev.bearing + 90);
    ev.robot.ahead(100);
    };

  30. mariuszklinger revised this gist Dec 9, 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
    @@ -43,6 +43,6 @@ Robot.prototype.isEnemy = function(ev){
    }

    Robot.prototype.onRobotCollision = function(ev) {

    ev.robot.turn(ev.bearing + 90);
    };