-
-
Save dudadornelles/4221822 to your computer and use it in GitHub Desktop.
Shrimp Hunter
This file contains 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 RobotState = function () { | |
data = {}; | |
data.isLookingAtTarget = false; | |
return data; | |
}; | |
var goodRobot = RobotState(); | |
var evilRobot = RobotState(); | |
var clonedEvilMe = false; | |
//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 (robot.parentId == null) { | |
if (!clonedEvilMe) { | |
robot.clone(); | |
clonedEvilMe = true; | |
} | |
if (!goodRobot.isLookingAtTarget) { | |
robot.turn(1); | |
goodRobot.isLookingAtTarget = false; | |
} | |
} | |
}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
if (ev.parentId == null) { | |
goodRobot.isLookingAtTarget = true; | |
robot.fire(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment