Skip to content

Instantly share code, notes, and snippets.

@samelinux
Created December 7, 2012 11:26
Show Gist options
  • Select an option

  • Save samelinux/4232667 to your computer and use it in GitHub Desktop.

Select an option

Save samelinux/4232667 to your computer and use it in GitHub Desktop.
To Delete
var eading;
var firesign;
var lasthealth;
var fired;
var Robot = function(robot) {
eading=1;
firesign=1;
lasthealth=100;
fired=false;
robot.rotateCannon(-90);
};
Robot.prototype.onIdle = function(ev) {
if(eading==1)
{
ev.robot.ahead(30);
}
else
{
ev.robot.back(30);
}
if(ev.robot.cannonRelativeAngle==300 || ev.robot.cannonRelativeAngle==60)
{
if(firesign==1)
{
firesign=-1;
}
else
{
firesign=1;
}
}
// if(!fired)
ev.robot.rotateCannon(10*firesign);
};
Robot.prototype.onHitByBullet = function(ev) {
eading=1-eading;
};
Robot.prototype.onScannedRobot = function(ev) {
// ev.robot.fire();
// ev.robot.rotateCannon(-20*firesign);
};
Robot.prototype.onRobotCollision = function(ev) {
eading=1-eading;
};
Robot.prototype.onWallCollision = function(ev) {
ev.robot.turn(ev.bearing - 90);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment