Skip to content

Instantly share code, notes, and snippets.

@byrichardpowell
Created December 3, 2012 17:14
Show Gist options
  • Save byrichardpowell/4196445 to your computer and use it in GitHub Desktop.
Save byrichardpowell/4196445 to your computer and use it in GitHub Desktop.
Budvar
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
var turn = 10;
var turned = 0;
var stop = false;
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if ( !stop ) {
robot.ahead(20);
robot.turn( turn );
robot.rotateCannon( turn *-1);
robot.fire();
turned += 10;
if ( turned >= 360 ) turn = -10
if ( turned <= 0 ) turn = 10
} else {
robot.fire();
robot.fire();
robot.fire();
stop = false
}
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment