Created
December 4, 2012 02:30
-
-
Save orian/4199989 to your computer and use it in GitHub Desktop.
Dzdzowniczka
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.prototype.lastHitAngle = -1; | |
Robot.prototype.radius = 20; | |
Robot.prototype.hit = 0; | |
Robot.prototype.onIdle = function(ev) { | |
var robot = ev.robot; | |
this.hit = 0; | |
if (this.lastHitAngle < 0) { | |
for (var i=0; this.hit == 0 && i < 10;++i) { | |
robot.rotateCannon(360/10); | |
robot.ahead(5 + i/3); | |
robot.turn(360/10 + i/4); | |
console.log("hit: "+hit); | |
} | |
} | |
if (this.lastHitAngle - robot.cannonAbsoluteAngle > 10) { | |
robot.rotateCannon(this.lastHitAngle - robot.cannonAbsoluteAngle); | |
} | |
robot.rotateCannon(this.radius); | |
this.radius = (-2*this.radius)%360; | |
if (this.hit==0) { | |
this.lastHitAngle = -1; | |
console.log("nie ma niczego"); | |
} | |
robot.turn(25); | |
robot.ahead(60); | |
robot.rotateCannon(-25); | |
}; | |
Robot.prototype.onScannedRobot = function(ev) { | |
var robot = ev.robot; | |
robot.fire(); | |
this.lastHitAngle = robot.cannonAbsoluteAngle; | |
this.radius = 10; | |
this.hit = this.hit +1 ; | |
console.log("hit jak nic"); | |
}; | |
// ohhh... we were hit by another robot... | |
Robot.prototype.onHitByBullet = function(ev) { | |
var robot; | |
robot = ev.robot; | |
robot.turn(90 - ev.bulletBearing); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment