Created
December 4, 2012 18:47
-
-
Save Isinlor/4207379 to your computer and use it in GitHub Desktop.
Lol2
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 odd = 1; | |
//FightCode canonlyunderstand your robot | |
//if its class is calledRobot | |
var Robot = function(robot) { | |
robot.clone(); | |
robot.turn(360); | |
}; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
//robot.rotateCannon(45); | |
robot.turn(45*odd); | |
robot.ahead(35); | |
//console.log(robot.life); | |
}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
var enemy = ev.scannedRobot; | |
//var bFriendly = ( robot.parentId !=null && robot.parentId==enemy.id); | |
//bFriendly |= ( enemy.parentId !=null && enemy.parentId==robot.id); | |
var scanned = ev.scannedRobot; | |
if(scanned.id !== robot.parentId && scanned.parentId !== robot.id) | |
{ | |
robot.stop(); | |
for (var i=0; i<4; i++) { | |
robot.fire(0);robot.fire(0); | |
robot.ahead(25); | |
// robot.turn(2); | |
robot.rotateCannon(30); | |
robot.rotateCannon(-30); | |
} | |
} | |
}; | |
Robot.prototype.onWallCollision = function(ev) { | |
var robot = ev.robot; | |
robot.turn(ev.bearing); | |
robot.back(151); | |
odd = odd*-1; | |
// turn enought to be in a straight | |
// angle with the wall. | |
}; | |
Robot.prototype.onHitByBullet = function(ev) { | |
var robot = ev.robot; | |
robot.turn(15*odd); // Turn to wherever the bullet was fired | |
robot.ahead(40); | |
if(robot.life < 30 && robot.life > 20){ | |
odd = odd*-1; | |
} | |
}; | |
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); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment