Created
December 3, 2012 17:36
-
-
Save samshull/4196608 to your computer and use it in GitHub Desktop.
W00t #1 YEAH!!!! (Zolmesiter)
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 Robot = function(robot){ | |
robot.turnLeft(robot.angle % 90); | |
//robot.turnGunRight(90); | |
robot.clone(); | |
this.direction = 1; | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
robot.ahead(1); | |
if (robot.parentId) { | |
//if (robot.cannonRelativeAngle > 270 || robot.cannonRelativeAngle < 90) { | |
// this.direction *= -1; | |
//} | |
//robot.turnGunRight(this.direction); | |
//robot.turnGunRight(180); | |
//robot.turnGunRight(-180); | |
} | |
}; | |
Robot.prototype.onWallCollision = function(ev) { | |
var robot = ev.robot; | |
if(!robot.parentId) | |
robot.turnRight(ev.bearing - 90); | |
else | |
robot.turnRight(ev.bearing + 90); | |
}; | |
Robot.prototype.onRobotCollision = function(ev) { | |
var robot = ev.robot, collidedRobot = ev.collidedRobot; | |
robot.ignore('onRobotCollision') | |
if (ev.bearing > -90 && ev.bearing < 90) { | |
robot.back(100); | |
} else { | |
robot.ahead(100); | |
} | |
if (robot.id != collidedRobot.parentId && robot.parentId != collidedRobot.id) { | |
robot.turnGunRight(ev.bearing - robot.cannonRelativeAngle); | |
robot.turnGunLeft(ev.bearing - robot.cannonRelativeAngle); | |
} | |
robot.listen('onRobotCollision') | |
}; | |
Robot.prototype.onHitByBullet = function(ev) { | |
}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot, scannedRobot = ev.scannedRobot; | |
if (robot.id == scannedRobot.parentId || robot.parentId == scannedRobot.id) { | |
return; | |
} | |
robot.fire(); | |
//robot.log('firing'); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment