[Home]Hi

Robo Home | Changes | Preferences | AllPages

This Is my second robot (out of 4) and my best robot so far.--DB


package dwb; import robocode.*; import java.awt.Color;

public class hi extends Robot {

       public void run() {
		// After trying out your robot, try uncommenting the import at the top,
		// and the next line:
		setColors(Color.red,Color.blue,new Color (45,34,145));
		while(true) {
			// Replace the next 4 lines with any behavior you would like
			ahead(10);
			turnRadarRight?(360);
			turnRight(25);
		}
	}

	/**
	 * onScannedRobot: What to do when you see another robot
	 */
	public void onScannedRobot(ScannedRobotEvent e) {
		if (e.getDistance()<200) {
			turnRight(e.getBearing());
			fire(2);
			ahead(100);
			fire(2);
		}
		else {
			turnRight(e.getBearing());
			fire(2);
		}
	}

	/**
	 * onHitByBullet?: What to do when you're hit by a bullet
	 */
	public void onHitByBullet?(HitByBulletEvent? e) {
		if (e.getDistance()<75)
			fire(3);
		turnRight(e.getBearing());
		fire(2);
		fire(2);
	}
	public void onHitRobot?(HitRobotEvent? e) {
		fire(3);
	}

}



Robo Home | Changes | Preferences | AllPages
Edit text of this page | View other revisions
Last edited May 12, 2006 18:50 EST by DB (diff)
Search: