Last active
December 11, 2015 05:28
-
-
Save cogumm/4551892 to your computer and use it in GitHub Desktop.
Daft Punk - Fight Robot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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