void onBulletHit(BulletHitEvent event)
This method is called when one of your bullets hits another robot. You may choose to do a diffrent action if this happens
Example:
@Override
public void onBulletHit(BulletHitEvent event) {
out.println("I hit " + event.getName() + "!");
}
void onBulletMissed(BulletMissedEvent event)
This method is called when one of your bullets misses, i.e. hits a wall.
Example:
@Override
public void onBulletMissed(BulletMissedEvent event) {
out.println("Drat, I missed.");
}
void onHitWall(HitWallEvent event)
This method is called when your robot collides with a wall.
The wall at the top of the screen is 0 degrees, right is 90 degrees, bottom is 180 degrees, left is 270 degrees. But this event is relative to your heading, so: The bearing is such that turnRight (event.getBearing()) will point you perpendicular to the wall.
Example:
@Override
void onHitWall(HitWallEvent event) {
out.println("Ouch, I hit a wall bearing " + event.getBearing() + " degrees.");
turnRight (event.getBearing());
}
void onHitRobot(HitRobotEvent event)
This method is called when your robot collides with another robot. This code safely gets your bot out of harms way, but maybe your bot might be more aggressive.
Example:
@Override
void onHitRobot(HitRobotEvent event) {
if (event.getBearing() > -90 && event.getBearing() <= 90) {
back(100);
} else {
ahead(100);
}
}