Skip to content

Instantly share code, notes, and snippets.

@brunoksato
Created December 7, 2012 12:44
Show Gist options
  • Save brunoksato/4233030 to your computer and use it in GitHub Desktop.
Save brunoksato/4233030 to your computer and use it in GitHub Desktop.
Fanta Uva
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