Skip to content

Instantly share code, notes, and snippets.

@mdonahoo
Forked from m1ko/robot.js
Created December 4, 2012 22:22
Show Gist options
  • Save mdonahoo/4209481 to your computer and use it in GitHub Desktop.
Save mdonahoo/4209481 to your computer and use it in GitHub Desktop.
pan rozowy wons
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
for(var i=0;i<5;i++)
{
robot.move(60);
robot.turn(45);
}
for(var i=0;i<5;i++)
{
robot.move(120);
robot.turn(-45);
}
};
Robot.prototype.onScannedRobot = function(ev) {
var robot = ev.robot;
robot.fire();
};
Robot.prototype.onHitByBullet = function(ev) {
var robot = ev.robot;
robot.turn(ev.bearing);
robot.fire();
};
Robot.prototype.onWallCollision = function(ev) {
var robot = ev.robot;
robot.turn(180);
robot.ahead(100);
};
Robot.prototype.onRobotCollision = function(ev) {
var robot = ev.robot;
if(robot.myFault)
{
robot.turn(150);
robot.ahead(100);
}else{
robot.turn(ev.bearing);
robot.fire();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment