Skip to content

Instantly share code, notes, and snippets.

@yfwu
Created December 6, 2012 11:23
Show Gist options
  • Save yfwu/4223803 to your computer and use it in GitHub Desktop.
Save yfwu/4223803 to your computer and use it in GitHub Desktop.
ZATIC_POWER ONCE
//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.rotateCannon(180);
robot.ahead(170);
robot.turn(20);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
robot.fire();// YAY!
robot.turn(4);
robot.ahead(50);
};
Robot.prototype.onHitByBullet = function(ev) {
var robot = ev.robot;
robot.turn(10);
robot.ahead(60);
robot.turn(ev.bearing); // Turn to wherever the bullet was fired
robot.fire();
robot.fire();
robot.fire();
robot.fire();
robot.turn(120);
};
Robot.prototype.onRobotCollision = function(ev) {
robot.fire();
robot.back(150);
robot.rotateCannon(200);
};
Robot.prototype.onWallCollision = function(ev) {
robot.back(30);
robot.turn(30);
robot.back(40);
robot.rotateCannon(360);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
robot.fire();
robot.fire();
robot.turn(30);
robot.back(40);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment