[Home]Xhehdy

Robo Home | Changes | Preferences | AllPages

This was my first robot an I havn't been able to get any of the bugs out of it (I think that I coded it wrong).-- DB


package dwb; import robocode.*; import java.awt.Color; public class Xedhy extends Robot {

	public void run() {
		while(true) {
			setColors(new Color(255,255,255),new Color(255,255,0),new Color(100,100,0));
			turnRadarRight?(3600);
			ahead(10000);
		}
	}
	public void onHitWall?(HitWallEvent? event) {
		out.println("HEY!");
		turnLeft(180);
	}
	public void onHitRobot?(HitRobotEvent? event) {
		out.println("Outta my way!");
		fire(3);
	}

	public void onScannedRobot(ScannedRobotEvent event) {
		out.println("I've got you in my sights.");
		if (event.getDistance()>100) {
			turnRight(event.getBearing());
			fireBullet(1);
			ahead(50);
			turnRadarLeft?(20);
		}
		else {
			turnLeft(event.getBearing());
			fireBullet(2);
			ahead(25);
			turnRadarLeft?(20);
		}
	}
	public void onHitByBullet?(HitByBulletEvent? event) {
		out.println("OUTCH!");
		turnRight(event.getBearing());
		fire(2);
		turnRadarLeft?(20);
	}
	public void onWin(WinEvent? event) {
		out.println("YES!!!!!!");
		turnRight(360);
		fire(1);
		turnLeft(360);
		fire(1);
	}
	public void onDeath(DeathEvent? event) {
		out.println("AAAAARRRRG!!!!");
	}	
}



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