Created
December 9, 2012 21:09
-
-
Save PattenR/4247031 to your computer and use it in GitHub Desktop.
5
This file contains 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 characters
var cloned = false; | |
var C = false; | |
var first = 1; | |
var direction = 0; | |
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 = ev.robot; | |
robot = ev.robot; | |
if (!C) | |
{ | |
robot.ahead(800); | |
first = true; | |
} | |
if(direction = 1) | |
{ | |
if (C) | |
{ | |
if((robot.gunCoolDownTime) === 0) | |
{ | |
robot.fire(); | |
} | |
else | |
{ | |
robot.ahead(1); | |
} | |
} | |
} | |
if(direction = 0){ | |
if (C) | |
{ | |
if((robot.gunCoolDownTime) === 0) | |
{ | |
robot.fire(); | |
} | |
else | |
{ | |
robot.ahead(1); | |
} | |
} | |
} | |
}; | |
// this method gets called whenever we hit another robot... | |
Robot.prototype.onRobotCollision = function(ev) | |
{ | |
robot = ev.robot; | |
robot.back(100); | |
robot.rotateCannon(90); | |
robot.rotateCannon(-180); | |
robot.rotateCannon(90); | |
}; | |
// this method gets called whenever we hit a wall... | |
Robot.prototype.onWallCollision = function(ev) | |
{ | |
robot = ev.robot; | |
C = true; | |
if (first == 1){ | |
robot.turn(ev.bearing); | |
robot.turn(90); | |
robot.rotateCannon(90); | |
first = 0; | |
} | |
if(direction == 1) | |
{ | |
robot.ahead(1000); | |
direction = 0; | |
} | |
if(direction == 0) | |
{ | |
robot.back(1000); | |
direction = 1; | |
} | |
}; | |
// yay we see another robot! time to wreak some havoc... | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
robot.fire(1); | |
robot.back(30); | |
robot.ahead(30); | |
}; | |
// ohhh... we were hit by another robot... | |
Robot.prototype.onHitByBullet = function(ev) { | |
var robot; | |
robot = ev.robot; | |
robot.back(300); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment