Skip to content

Instantly share code, notes, and snippets.

@brunoksato
Created December 7, 2012 12:56
Show Gist options
  • Save brunoksato/4233094 to your computer and use it in GitHub Desktop.
Save brunoksato/4233094 to your computer and use it in GitHub Desktop.
Fant Dan's
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.turn(10);
robot.ahead(25);
// robot.fire(1);
robot.rotateCannon(15);
// robot.turn(25);
};
// this method gets called whenever we hit another robot...
Robot.prototype.onRobotCollision = function(ev) {
robot.turn(ev.bearing);
robot.rotateCannon(360);
robot.fire(1);};
// this method gets called whenever we hit a wall...
// yay we see another robot! time to wreak some havoc...
Robot.prototype.onScannedRobot = function(ev) {
var robot;
robot = ev.robot;
robot.fire(1);
robot.turnGunRight(-5);
robot.turnGunRight(-15);
robot.ahead(-5);
};
// ohhh... we were hit by another robot...
Robot.prototype.onHitByBullet = function(ev) {
var robot;
robot = ev.robot;
robot.turn(25);
robot.ahead(150);
robot.turnGunRight(-75);
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.turn(35-ev.bearing); // turn enought to be in a straight
// robot.ahead(50);
// angle with the wall.
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment