Skip to content

Instantly share code, notes, and snippets.

@PattenR
Created December 9, 2012 21:09
Show Gist options
  • Save PattenR/4247026 to your computer and use it in GitHub Desktop.
Save PattenR/4247026 to your computer and use it in GitHub Desktop.
3
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