Skip to content

Instantly share code, notes, and snippets.

@dlion
Created December 7, 2012 00:45
Show Gist options
  • Select an option

  • Save dlion/4229792 to your computer and use it in GitHub Desktop.

Select an option

Save dlion/4229792 to your computer and use it in GitHub Desktop.
Smagen
//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(360);
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
var enemy = ev.scannedRobot;
robot.fire(1);
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
// trying to run away
var enemy = ev.collidedRobot;
robot.rotateCannon(enemy.angle);
robot.back(100);
};
Robot.prototype.onHitByBullet = function(ev) {
var robot;
robot = ev.robot;
robot.turn(90 - ev.bulletBearing);
};
@dlion
Copy link
Copy Markdown
Author

dlion commented Dec 12, 2012

It sucks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment