Skip to content

Instantly share code, notes, and snippets.

@S3Mi
Created December 4, 2012 13:33
Show Gist options
  • Select an option

  • Save S3Mi/4203914 to your computer and use it in GitHub Desktop.

Select an option

Save S3Mi/4203914 to your computer and use it in GitHub Desktop.
bulbator_v0.3
var Robot = function(robot) {};
var angle = 20;
var curAngle = angle;
var targetingAngle = 10;
var idleCyclesWOEnemy = 0;
var cycles = 0;
var targetCycles = 3;
var targeting = false;
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if(targeting){
robot.rotateCannon(targetingAngle);
cycles++;
if(cycles == targetCycles){
targetingAngle = -targetingAngle;
cycles = 0;
}
} else {
robot.ahead(10);
robot.rotateCannon(angle);
}
idleCyclesWOEnemy++;
if(idleCyclesWOEnemy >= 10){
targeting = false;
}
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
targeting = true;
//cycles = 0;
idleCyclesWOEnemy = 0;
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.turn(-ev.bearing); // turn enought to be in a straight
// angle with the wall.
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment