-
-
Save brunoksato/4234616 to your computer and use it in GitHub Desktop.
Revisions
-
yuyi revised this gist
Dec 6, 2012 . No changes.There are no files selected for viewing
-
yuyi revised this gist
Dec 6, 2012 . 1 changed file with 25 additions and 55 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 @@ -1,63 +1,33 @@ function Robot(robot) {} // well, we need to do something... // whenever our robot is idle, this method gets called. Robot.prototype.onIdle = function(ev) { var robot; robot = ev.robot; robot.ahead(150); robot.rotateCannon(360); robot.back(100); robot.rotateCannon(360); robot.turn(20); }; // this method gets called whenever we hit another robot... Robot.prototype.onRobotCollision = function(ev) {}; // this method gets called whenever we hit a wall... Robot.prototype.onWallCollision = function(ev) {}; // yay we see another robot! time to wreak some havoc... Robot.prototype.onScannedRobot = function(ev) { var robot; robot = ev.robot; robot.fire(1); }; // ohhh... we were hit by another robot... Robot.prototype.onHitByBullet = function(ev) { var robot; robot = ev.robot; robot.turn(90 - ev.bulletBearing); }; -
yuyi revised this gist
Dec 6, 2012 . 1 changed file with 14 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 @@ -1,15 +1,21 @@ var Robot = function(robot) { robot.rotateCannon(-90); }; var x_target = -1; var y_target = -1; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(); //robot.rotateCannon(-0.0005); //i'll add a clone but i need to refactor collision //robot.clone(); if(x_target == -1) { x_target = robot.arenaWidth / 2; y_target = robot.arenaHeight / 2; } var x = robot.position.x; var y = robot.position.y; var dx = x_target - x; @@ -18,6 +24,7 @@ Robot.prototype.onIdle = function(ev) { var deg = Math.atan2(dy,dx)*360/2/pi+180; var ddeg = (deg-robot.cannonAbsoluteAngle+180 + 360*10)%360-180; robot.rotateCannon(ddeg); //if (ddeg > 10 || ddeg < 10) //console.log(ddeg,x,x_target,y,robot.cannonAbsoluteAngle); }; @@ -27,8 +34,11 @@ Robot.prototype.onScannedRobot = function(ev) { var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); //robot.rotateCannon(-10); //robot.rotateCannon(15); x_target = scanned.position.x; y_target = scanned.position.y; }else{ } -
yuyi revised this gist
Dec 6, 2012 . 1 changed file with 13 additions and 2 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 @@ -8,6 +8,18 @@ Robot.prototype.onIdle = function(ev) { //robot.rotateCannon(-0.0005); //i'll add a clone but i need to refactor collision //robot.clone(); var x_target = robot.arenaWidth / 2; var y_target = robot.arenaHeight / 2; var x = robot.position.x; var y = robot.position.y; var dx = x_target - x; var dy = y_target - y; var pi = 3.1415927; var deg = Math.atan2(dy,dx)*360/2/pi+180; var ddeg = (deg-robot.cannonAbsoluteAngle+180 + 360*10)%360-180; robot.rotateCannon(ddeg); //if (ddeg > 10 || ddeg < 10) //console.log(ddeg,x,x_target,y,robot.cannonAbsoluteAngle); }; Robot.prototype.onScannedRobot = function(ev) { @@ -37,6 +49,5 @@ Robot.prototype.onRobotCollision = function(ev) { Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(-90+ev.bearing); }; -
yuyi revised this gist
Dec 6, 2012 . 1 changed file with 3 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 @@ -5,7 +5,7 @@ robot.rotateCannon(-90); Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(); //robot.rotateCannon(-0.0005); //i'll add a clone but i need to refactor collision //robot.clone(); }; @@ -37,4 +37,6 @@ Robot.prototype.onRobotCollision = function(ev) { Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(-90+ev.bearing); robot.rotateCannon(-90+ev.bearing); }; -
yuyi revised this gist
Dec 6, 2012 . 1 changed file with 1 addition 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 @@ -5,7 +5,7 @@ robot.rotateCannon(-90); Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(); robot.rotateCannon(-0.0005); //i'll add a clone but i need to refactor collision //robot.clone(); }; -
yuyi revised this gist
Dec 6, 2012 . 1 changed file with 1 addition 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 @@ -5,7 +5,7 @@ robot.rotateCannon(-90); Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(); robot.rotateCannon(-0.005); //i'll add a clone but i need to refactor collision //robot.clone(); }; -
yuyi revised this gist
Dec 6, 2012 . 1 changed file with 1 addition 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 @@ -24,7 +24,7 @@ Robot.prototype.onScannedRobot = function(ev) { }; Robot.prototype.onHitByBullet = function(ev) { var robot = ev.robot; //robot.turn(ev.bearing); // Turn to wherever the bullet was fired // so we can see who shot it }; -
yuyi revised this gist
Dec 6, 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 @@ -23,8 +23,11 @@ Robot.prototype.onScannedRobot = function(ev) { }; Robot.prototype.onHitByBullet = function(ev) { var robot = ev.robot; robot.turn(ev.bearing); // Turn to wherever the bullet was fired // so we can see who shot it }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; -
yuyi revised this gist
Dec 6, 2012 . No changes.There are no files selected for viewing
-
yuyi revised this gist
Dec 6, 2012 . 1 changed file with 1 addition 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 @@ -5,7 +5,7 @@ robot.rotateCannon(-90); Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(); robot.rotateCannon(0.5); //i'll add a clone but i need to refactor collision //robot.clone(); }; -
yuyi revised this gist
Dec 6, 2012 . 1 changed file with 1 addition 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 @@ -5,6 +5,7 @@ robot.rotateCannon(-90); Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(); robot.rotateCannon(5); //i'll add a clone but i need to refactor collision //robot.clone(); }; -
yuyi revised this gist
Dec 6, 2012 . No changes.There are no files selected for viewing
-
yuyi revised this gist
Dec 6, 2012 . No changes.There are no files selected for viewing
-
yuyi created this gist
Dec 6, 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,36 @@ var Robot = function(robot) { robot.rotateCannon(-90); }; Robot.prototype.onIdle = function(ev) { var robot = ev.robot; robot.ahead(); //i'll add a clone but i need to refactor collision //robot.clone(); }; Robot.prototype.onScannedRobot = function(ev) { var robot = ev.robot; var scanned =ev.scannedRobot; if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) { robot.fire(); robot.rotateCannon(-10); //robot.rotateCannon(15); }else{ } }; Robot.prototype.onHitByBullet = function(ev) { var robot; }; Robot.prototype.onRobotCollision = function(ev) { var robot = ev.robot; robot.rotateCannon(90); }; Robot.prototype.onWallCollision = function(ev) { var robot = ev.robot; robot.turn(-90+ev.bearing); };