-
-
Save MauMaGau/4208168 to your computer and use it in GitHub Desktop.
MauMaGau Return of the Mau
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//FightCode can only understand your robot | |
//if its class is called Robot | |
var Robot = function(robot) { | |
robot.clone(); | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
if(robot.parentId) { | |
robot.turn(1); | |
robot.ahead(1); | |
robot.rotateCannon(10); | |
} | |
else { | |
robot.turn(-5); | |
robot.ahead(-5); | |
robot.rotateCannon(-5); | |
} | |
}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
var sr = ev.scannedRobot; | |
robot.stop() | |
var friendly = ( robot.parentId !=null && robot.parentId==sr.id); | |
friendly |= ( sr.parentId !=null && sr.parentId==robot.id); | |
if(!friendly){ | |
robot.fire(); | |
robot.rotateCannon(-30); | |
robot.fire(); | |
robot.rotateCannon(30); | |
robot.fire(); | |
if(robot.parentId){ | |
robot.rotateCannon(40); | |
}else{ | |
robot.rotateCannon(-40); | |
} | |
} | |
}; | |
Robot.prototype.onWallCollision = function(ev) { | |
var robot; | |
robot = ev.robot; | |
robot.stop() | |
if(robot.parentId){ | |
robot.turn(90); | |
}else{ | |
robot.turn(-90); | |
} | |
}; | |
Robot.prototype.onHitByBullet = function(ev) { | |
var robot = ev.robot; | |
robot.stop() | |
robot.ahead(100); | |
robot.rotateCannon(ev.bearing); | |
}; | |
Robot.prototype.onRobotCollision = function(ev) { | |
var robot = ev.robot; | |
robot.stop() | |
//robot.rotateCannon(20); | |
robot.back(40); | |
robot.turn(40); | |
// trying to run away | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment