Skip to content

Instantly share code, notes, and snippets.

@samelinux
Created December 5, 2012 14:24
Show Gist options
  • Select an option

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

Select an option

Save samelinux/4215862 to your computer and use it in GitHub Desktop.
To Delete
var Robot=function(robot)
{
robot.clone();
};
Robot.prototype.onIdle=function(ev)
{
var io=ev.robot;
io.ahead(10);
if(io.parentId)
{
io.rotateCannon(10);
}
else
{
io.rotateCannon(-10);
}
};
Robot.prototype.onScannedRobot=function(ev)
{
var io=ev.robot;
var nemico=ev.scannedRobot;
if (io.id==nemico.parentId || io.parentId==nemico.id)
{
return;
}
// io.fire();
if(io.parentId)
{
io.rotateCannon(-25);
}
else
{
io.rotateCannon(25);
}
};
Robot.prototype.onRobotCollision=function(ev)
{
var io=ev.robot;
var nemico=ev.collidedRobot;
if (io.id==nemico.parentId || io.parentId==nemico.id)
{
io.turn(180);
io.ahead(10);
}
else
{
io.turn(-ev.bearing);
}
}
Robot.prototype.onWallCollision=function(ev)
{
var io=ev.robot;
io.ignore('onRobotCollision');
io.turn(180);
io.listen('onRobotCollision');
}
Robot.prototype.onHitByBullet=function(ev)
{
var io=ev.robot;
io.turn(180);
o.ahead(10);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment