Skip to content

Instantly share code, notes, and snippets.

@samelinux
Forked from zachiPL/robot.js
Created December 7, 2012 10:27
Show Gist options
  • Select an option

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

Select an option

Save samelinux/4232357 to your computer and use it in GitHub Desktop.
OpenBarbarian
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(!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