Skip to content

Instantly share code, notes, and snippets.

@ticolucci
Created December 8, 2012 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ticolucci/4240093 to your computer and use it in GitHub Desktop.
Save ticolucci/4240093 to your computer and use it in GitHub Desktop.
MegaMan
var Robot = function(robot) {};
var searching = true;
var direction = 1;
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
if (searching) {
robot.rotateCannon(90);
searching = false;
}
if(! robot.parentId){
robot.fire()
robot.ahead(3)
}
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
var enemy = ev.scannedRobot;
i
};
Robot.prototype.onHitByBullet = function(ev) {
var robot = ev.robot;
//this.pauseAsyncFn("asyncCannon", 2, robot.id);
};
Robot.prototype.onWallCollision = function(ev) {
if(!ev.robot.parentId)
ev.robot.turn(30);
};
Robot.prototype.onRobotCollision = function(ev){
if(!ev.robot.parentId)
ev.robot.turn(30);
direction = -1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment