Skip to content

Instantly share code, notes, and snippets.

@cogumm
Last active December 11, 2015 05:28
Show Gist options
  • Save cogumm/4551892 to your computer and use it in GitHub Desktop.
Save cogumm/4551892 to your computer and use it in GitHub Desktop.
Daft Punk - Fight Robot
var cannonRotated = false;
var Robot = function(robot) {
robot.rotateCannon(-90);
cannonRotated = true;
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if (!cannonRotated){
robot.rotateCannon(-90);
cannonRotated = true;
}
robot.ahead();
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
robot.rotateCannon(-22.5);
robot.rotateCannon(22.5);
//robot.stop();
//robot.clone();
//robot.fire();
robot.ahead(100);
};
Robot.prototype.onHitByBullet = function(ev) {
var robot = ev.robot;
robot.rotate(-30);
robot.back(100);
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
robot.rotateCannon(90);
cannonRotated = false;
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.turn(-90+ev.bearing);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment