package js; import robocode.*; import java.awt.Color; /** * Put2shame - a robot by (your name here) */ public class Put2shame extends Robot { int turnDirection = 1; // Clockwise or counterclockwise /** * run: Put2shame's default behavior */ public void run() { // After trying out your robot, try uncommenting the import at the top, // and the next line: //setColors(Color.red); while(true) { // Replace the next 4 lines with any behavior you would like turnRight(5 * turnDirection); ahead(100); turnGunRight(360); back(100); turnGunRight(360); } } /** * onScannedRobot: What to do when you see another robot */ public void onScannedRobot(ScannedRobotEvent e) { fire(1); turnRight(90); turnGunLeft(90); //turnRight(e.getBearing()); } /** * onHitByBullet: What to do when you're hit by a bullet */ public void onHitByBullet(HitByBulletEvent e) { turnLeft(90 - e.getBearing()); } }