Skip to content

Instantly share code, notes, and snippets.

@Firvagor
Forked from Walko/robot.js
Created December 4, 2012 14:59
Show Gist options
  • Save Firvagor/4204827 to your computer and use it in GitHub Desktop.
Save Firvagor/4204827 to your computer and use it in GitHub Desktop.
Sperminator
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(1);
robot.rotateCannon(360);
robot.ahead(1);
//robot.back(1000);
// robot.rotateCannon(360);
// robot.turn(20);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
// robot.fire(4);
// robot.rotateCannon(0,1);
// robot.fire(1);
// robot.rotateCannon(0,1);
//robot.rotateCannon(10);
// robot.turn(50);
//robot.ahead(5000);
robot.stop();
robot.fire();
robot.turn(15);
robot.ahead(0,5);
robot.rotateCannon(-30);
robot.fire();
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
robot.fire(5);
robot.turn(200);
robot.ahead(500); // trying to run away
robot.clone(robot);
};
Robot.prototype.onHitByBullet = function(ev) {
var robot;
robot = ev.robot;
robot.turn(10 - ev.bulletBearing);
robot.back(70);
robot.ahead(70);
};
//Robot.prototype.onScannedRobot = function(ev) {
// var robot;
// var robot1;
//var scanned =ev.scannedRobot;
//robot = ev.robot;
//robot.fire(5);
// robot1.clone(robot);
// if(scannedRobot !== robot1.parentId && scanned.parentId !== robot1.id)
// robot1.fire(2);
//};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment