Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## robocode.robotinterfaces
Interface IBasicEvents

All Known Implementing Classes:
  _AdvancedRadiansRobot, _AdvancedRobot, AdvancedRobot, Robot, TeamRobot

    public interface IBasicEvents

An event interface for receiving basic robot events with an `IBasicRobot`.

Since:
  1.6
Author:
  Pavel Savara (original), Flemming N. Larsen (javadoc)
See Also:
  `IBasicRobot`

Method Summary
`void` | `onBulletHit(BulletHitEvent event)` This method is called when one of your bullets hits another robot.
`void` | `onBulletHitBullet(BulletHitBulletEvent event)` This method is called when one of your bullets hits another bullet.
`void` | `onBulletMissed(BulletMissedEvent event)` This method is called when one of your bullets misses, i.e. hits a wall.
`void` | `onDeath(DeathEvent event)` This method is called if your robot dies.
`void` | `onHitByBullet(HitByBulletEvent event)` This method is called when your robot is hit by a bullet.
`void` | `onHitRobot(HitRobotEvent event)` This method is called when your robot collides with another robot.
`void` | `onHitWall(HitWallEvent event)` This method is called when your robot collides with a wall.
`void` | `onRobotDeath(RobotDeathEvent event)` This method is called when another robot dies.
`void` | `onScannedRobot(ScannedRobotEvent event)` This method is called when your robot sees another robot, i.e. when the robot's radar scan "hits" another robot.
`void` | `onStatus(StatusEvent event)` This method is called every turn in a battle round in order to provide the robot status as a complete snapshot of the robot's current state at that specific time.
`void` | `onWin(WinEvent event)` This method is called if your robot wins a battle.

Method Detail

### onStatus

    void onStatus(StatusEvent event)

  This method is called every turn in a battle round in order to provide the robot status as a complete snapshot of the robot's current state at that specific time.

  The main benefit of this method is that you'll automatically receive all current data values of the robot like e.g. the x and y coordinate, heading, gun heat etc., which are grouped into the exact same time/turn.

  This is the only way to map the robots data values to a specific time. For example, it is not possible to determine the exact time of the robot's heading by calling first calling `Robot.getTime()` and then `Robot.getHeading()` afterwards, as the time might change after between the `Robot.getTime()` and `Robot.getHeading()` call.

  Parameters:
    `event` - the event containing the robot status at the time it occurred.
  Since:
    1.5

### onBulletHit

    void onBulletHit(BulletHitEvent event)

  This method is called when one of your bullets hits another robot. You should override it in your robot if you want to be informed of this event.

  Example:

         public void onBulletHit(BulletHitEvent event) {
             out.println("I hit " + event.getName() + "!");
         }

  Parameters:
    `event` - the bullet-hit event set by the game
  See Also:
    `BulletHitEvent`, `Event`

### onBulletHitBullet

    void onBulletHitBullet(BulletHitBulletEvent event)

  This method is called when one of your bullets hits another bullet. You should override it in your robot if you want to be informed of this event.

  Example:

         public void onBulletHitBullet(BulletHitBulletEvent event) {
             out.println("I hit a bullet fired by " + event.getBullet().getName() + "!");
         }

  Parameters:
    `event` - the bullet-hit-bullet event set by the game
  See Also:
    `BulletHitBulletEvent`, `Event`

### onBulletMissed

    void onBulletMissed(BulletMissedEvent event)

  This method is called when one of your bullets misses, i.e. hits a wall. You should override it in your robot if you want to be informed of this event.

  Example:

         public void onBulletHit(BulletMissedEvent event) {
             out.println("Drat, I missed.");
         }

  Parameters:
    `event` - the bullet-missed event set by the game
  See Also:
    `BulletMissedEvent`, `Event`

### onDeath

    void onDeath(DeathEvent event)

  This method is called if your robot dies.

  You should override it in your robot if you want to be informed of this event. Actions will have no effect if called from this section. The intent is to allow you to perform calculations or print something out when the robot is killed.

  Parameters:
    `event` - the death event set by the game
  See Also:
    `DeathEvent`, `Event`

### onHitByBullet

    void onHitByBullet(HitByBulletEvent event)

  This method is called when your robot is hit by a bullet. You should override it in your robot if you want to be informed of this event.

  Example:

         void onHitByBullet(HitByBulletEvent event) {
             out.println(event.getRobotName() + " hit me!");
         }

  Parameters:
    `event` - the hit-by-bullet event set by the game
  See Also:
    `HitByBulletEvent`, `Event`

### onHitRobot

    void onHitRobot(HitRobotEvent event)

  This method is called when your robot collides with another robot. You should override it in your robot if you want to be informed of this event.

  Example:

         void onHitRobot(HitRobotEvent event) {
             if (event.getBearing() > -90 && event.getBearing() <= 90) {
                 back(100);
             } else {
                 ahead(100);
             }
         }

         -- or perhaps, for a more advanced robot --

         public void onHitRobot(HitRobotEvent event) {
             if (event.getBearing() > -90 && event.getBearing() <= 90) {
                 setBack(100);
             } else {
                 setAhead(100);
             }
         }

  The angle is relative to your robot's facing. So 0 is straight ahead of you.

  This event can be generated if another robot hits you, in which case `event.isMyFault()` will return `false`. In this case, you will not be automatically stopped by the game -- but if you continue moving toward the robot you will hit it (and generate another event). If you are moving away, then you won't hit it.

  Parameters:
    `event` - the hit-robot event set by the game
  See Also:
    `HitRobotEvent`, `Event`

### onHitWall

    void onHitWall(HitWallEvent event)

  This method is called when your robot collides with a wall. You should override it in your robot if you want to be informed of this event.

  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:

         void onHitWall(HitWallEvent event) {
             out.println("Ouch, I hit a wall bearing " + event.getBearing() + " degrees.");
         }

  Parameters:
    `event` - the hit-wall event set by the game
  See Also:
    `HitWallEvent`, `Event`

### onScannedRobot

    void onScannedRobot(ScannedRobotEvent event)

  This method is called when your robot sees another robot, i.e. when the robot's radar scan "hits" another robot. You should override it in your robot if you want to be informed of this event. (Almost all robots should override this!)

  This event is automatically called if there is a robot in range of your radar.

  Note that the robot's radar can only see robot within the range defined by `Rules.RADAR_SCAN_RADIUS` (1200 pixels).

  Also not that the bearing of the scanned robot is relative to your robot's heading.

  Example:

         void onScannedRobot(ScannedRobotEvent event) {
             // Assuming radar and gun are aligned...
             if (event.getDistance() < 100) {
                 fire(3);
             } else {
                 fire(1);
             }
         }

  Note:
  The game assists Robots in firing, as follows:
  - If the gun and radar are aligned (and were aligned last turn),
  - and the event is current,
  - and you call fire() before taking any other actions, `fire()` will fire directly at the robot.

  In essence, this means that if you can see a robot, and it doesn't move, then fire will hit it.

  AdvancedRobots will NOT be assisted in this manner, and are expected to examine the event to determine if `fire()` would hit. (i.e. you are spinning your gun around, but by the time you get the event, your gun is 5 degrees past the robot).

  Parameters:
    `event` - the scanned-robot event set by the game
  See Also:
    `ScannedRobotEvent`, `Event`, `Rules.RADAR_SCAN_RADIUS`

### onRobotDeath

    void onRobotDeath(RobotDeathEvent event)

  This method is called when another robot dies. You should override it in your robot if you want to be informed of this event.

  Parameters:
    `event` - The robot-death event set by the game
  See Also:
    `RobotDeathEvent`, `Event`

### onWin

    void onWin(WinEvent event)

  This method is called if your robot wins a battle.

  Your robot could perform a victory dance here! :-)

  Parameters:
    `event` - the win event set by the game
  See Also:
    `WinEvent`, `Event`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD