Skip to content

Instantly share code, notes, and snippets.

@KimiTang
Forked from samelinux/robot.js
Created December 8, 2012 02:54
Show Gist options
  • Save KimiTang/4238341 to your computer and use it in GitHub Desktop.
Save KimiTang/4238341 to your computer and use it in GitHub Desktop.
Wall Killer
var Robot = function(robot) {
robot.rotateCannon(180);
};
Robot.prototype.onIdle = function(ev) {
ev.robot.back(30);
};
Robot.prototype.onScannedRobot = function(ev) {
ev.robot.fire();
};
Robot.prototype.onWallCollision = function(ev) {
ev.robot.ignore("onRobotCollision");
ev.robot.ignore("onScannedRobot");
ev.robot.turn(ev.bearing - 90);
ev.robot.listen("onScannedRobot");
ev.robot.listen("onRobotCollision");
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment