Created
December 4, 2012 15:57
-
-
Save lekoder/4205450 to your computer and use it in GitHub Desktop.
Revisions
-
lekoder revised this gist
Dec 5, 2012 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -38,9 +38,12 @@ Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; robot.stop(); robot.fire(); opts.aim=5; var ta = ev.robot.cannonRelativeAngle; if ( ta>180 ) ta -=360; if ( ta>20 ) ta=20; if ( ta<-20 ) ta=-20; robot.turn(ta); robot.rotateCannon(-ta); }; -
lekoder revised this gist
Dec 4, 2012 . 1 changed file with 13 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -49,3 +49,16 @@ Robot.prototype.onWallCollision = function(ev) { opts.fwd = !opts.fwd; } Robot.prototype.onRobotCollision = function(ev) { opts.fwd = !opts.fwd; var ta = ev.bearing - ev.robot.cannonRelativeAngle; robot.rotateCannon(ta); } Robot.prototype.onHitByBullet = function(ev) { opts.fwd = !opts.fwd; var ta = ev.bearing - ev.robot.cannonRelativeAngle; robot.rotateCannon(ta); } -
lekoder revised this gist
Dec 4, 2012 . 1 changed file with 13 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,12 +22,16 @@ Robot.prototype.onIdle = function(ev) { else { robot.rotateCannon(-3); } if ( opts.fwd ) { robot.ahead(10); } else { robot.back(10); } }; Robot.prototype.onScannedRobot = function(ev) { @@ -38,5 +42,10 @@ Robot.prototype.onScannedRobot = function(ev) { var ta = ev.robot.cannonRelativeAngle; if ( ta>180 ) ta -=360; robot.turn(ta); robot.rotateCannon(-ta); }; Robot.prototype.onWallCollision = function(ev) { opts.fwd = !opts.fwd; } -
lekoder revised this gist
Dec 4, 2012 . 1 changed file with 23 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,16 +5,36 @@ var Robot = function(robot) { }; var opts = { aim:0, fwd:true } Robot.prototype.onIdle = function(ev) { var robot = ev.robot; if (opts.aim>0) { robot.rotateCannon(10); robot.rotateCannon(-10); opts.aim--; } else { robot.rotateCannon(-3); if ( opts.fwd ) { robot.ahead(10); } else { robot.back(10); } }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; robot.stop(); robot.fire(); opts.aim=20; var ta = ev.robot.cannonRelativeAngle; if ( ta>180 ) ta -=360; robot.turn(ta); -
lekoder created this gist
Dec 4, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal 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.rotateCannon(36); robot.ahead(10); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; robot.stop(); var ta = ev.robot.cannonRelativeAngle; if ( ta>180 ) ta -=360; robot.turn(ta); };