Skip to content

Instantly share code, notes, and snippets.

@deluan
Forked from kjaku/robot.js
Created December 8, 2012 15:42
Show Gist options
  • Save deluan/4240786 to your computer and use it in GitHub Desktop.
Save deluan/4240786 to your computer and use it in GitHub Desktop.
Bubu
var Robot = function(robot) {
// var robot = ev.robot;
}
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.clone();
robot.rotateCannon(360);
robot.turn(360)
// robot.ahead(100);
// robot.back(100)
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
var scanned =ev.scannedRobot;
if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) {
robot.fire();
robot.rotateCannon(-25);
robot.ahead(10);
}else{
// robot.back(50);
}
};
Robot.prototype.onHitByBullet = function(ev) {
var robot;
robot = ev.robot;
robot.turn(90 - ev.bulletBearing);
robot.ahead(30);
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.turn(ev.bearing); // turn enought to be in a straight
robot.back(100); // angle with the wall.
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment