Skip to content

Instantly share code, notes, and snippets.

@flyingmachine
Created December 5, 2012 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flyingmachine/4215523 to your computer and use it in GitHub Desktop.
Save flyingmachine/4215523 to your computer and use it in GitHub Desktop.
Jabroney
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(20);
robot.rotateCannon(45);
var r = robot.position.x % 2
console.log(r)
if (r >= 1) {
robot.turn(20);
} else {
robot.turn(-20);
}
};
// this method gets called whenever we hit another robot...
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
robot.back(30);
};
// 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(5);
robot.rotateCannon(-45);
};
// ohhh... we were hit by another robot...
Robot.prototype.onHitByBullet = function(ev) {
var robot;
robot = ev.robot;
robot.turn(90 - ev.bulletBearing);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment