Skip to content

Instantly share code, notes, and snippets.

@rafaelcaricio
Created December 4, 2012 21:01
Show Gist options
  • Save rafaelcaricio/4208634 to your computer and use it in GitHub Desktop.
Save rafaelcaricio/4208634 to your computer and use it in GitHub Desktop.
Mother of Gods
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
robot.clone();
this.ascending = true;
robot.ahead(100);
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(100);
robot.rotateCannon(-360);
robot.ahead(100)
robot.rotateCannon(-360);
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.back(100);
};
Robot.prototype.onHitByBullet = function(ev) {
var robot = ev.robot;
robot.ahead(50);
robot.turn(45);
}
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
var enemy = ev.scannedRobot;
var bFriendly = ( robot.parentId !=null && robot.parentId==enemy.id);
bFriendly |= (enemy.parentId !=null && enemy.parentId==robot.id);
if (enemy.parentId) return;
if(!bFriendly) {
// clone
robot.fire();
robot.rotateCannon(3);
//if (this.ascending) {
robot.rotateCannon(30);
//} else {
// robot.rotateCannon(10);
// }
// original
//robot.fire();
//robot.rotateCannon(3)
//robot.rotateCannon(-30);
robot.turn(10);
robot.back(10);
} else {
robot.ahead(30);
robot.turn(25);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment