Created
December 4, 2012 22:09
-
-
Save yitsushi/4209354 to your computer and use it in GitHub Desktop.
Folyam
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
var cloned = false; | |
var cloneTick = 0; | |
//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; | |
if (!cloned && robot.parentId == null) { | |
robot.clone(); | |
robot.back(100); | |
cloned = true; | |
} else { | |
// robot.log(robot.parentId); | |
} | |
robot.ahead(100); | |
robot.rotateCannon(360); | |
robot.turn(90); | |
robot.ahead(200); | |
robot.rotateCannon(360); | |
robot.gunCoolDownTime = 0; | |
robot.life = 100; | |
}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
if (robot.parentId != ev.scannedRobot.id | |
&& robot.id != ev.scannedRobot.parentId) { | |
robot.fire(); | |
robot.fire(); | |
robot.fire(); | |
} | |
robot.back(100); | |
robot.turn(180-ev.scannedRobot.angle); | |
robot.ahead(100); | |
}; | |
Robot.prototype.onHitByBullet = function(ev) { | |
var robot; | |
robot = ev.robot; | |
robot.turn(90 - ev.bearing); | |
robot.ahead(100); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment