Skip to content

Instantly share code, notes, and snippets.

@yfwu
Created December 6, 2012 23:42
Show Gist options
  • Save yfwu/4229460 to your computer and use it in GitHub Desktop.
Save yfwu/4229460 to your computer and use it in GitHub Desktop.
ZATIC_POWER TRIA
//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(5);
robot.rotateCannon(12);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire(8);
robot.rotateCannon(15);
robot.turn(5);
robot.back(15);
robot.rotateCannon(-25);
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
// turn enought to be in a straight
robot.tuen(ev.bearing+50);
robot.back(45);// angle with the wall.
};
Robot.prototype.onHitByBullet = function(ev) {
var robot = ev.robot;
robot.ahead(240);// so we can see who shot it
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment