HitByBulletEvent

Package | Class | Use | Tree | Serialized | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## robocode
Class HitByBulletEvent

    java.lang.Object
      robocode.Event
          robocode.HitByBulletEvent

All Implemented Interfaces:
  Comparable

public class HitByBulletEvent
extends Event

A HitByBulletEvent is sent to `Robot.onHitByBullet(robocode.HitByBulletEvent)` when you are hit by a bullet. You can use the information contained in this event to determine what to do.

Constructor Summary
`HitByBulletEvent(double bearing, Bullet bullet)` Called by the game to create a new HitByBulletEvent.

Method Summary
`double` | `getBearing()` Returns the bearing to the bullet.
`double` | `getBearingRadians()` Returns the bearing to the bullet.
`Bullet` | `getBullet()` Returns the Bullet that hit you.
`double` | `getHeading()` Returns the direction the bullet was heading when it hit you, in degrees (0 <= getHeading() < 360) This is not relative to the direction you are facing.
`double` | `getHeadingDegrees()` Deprecated. use getHeading
`double` | `getHeadingRadians()` Returns the direction the bullet was heading when it hit you, in radians (0 <= getHeading() < 2 * PI) This is not relative to the direction you are facing.
`String` | `getName()` Returns the name of the robot that fired this bullet
`double` | `getPower()` Returns the power of this bullet.
`double` | `getVelocity()` Returns the velocity of this bullet.

Methods inherited from class robocode.Event
`compareTo, getPriority, getTime, setPriority, setTime`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### HitByBulletEvent

    public HitByBulletEvent(double bearing,
                            Bullet bullet)

  Called by the game to create a new HitByBulletEvent.

Method Detail

### getBearing

    public double getBearing()

  Returns the bearing to the bullet. If you were to turnRight(e.getBearing()), you would be facing the direction the bullet came from. The calculation used here is: (bullet's heading + 180) - (your heading) -180 < bearing <= 180

  Returns:
    bearing to the bullet.

### getBearingRadians

    public double getBearingRadians()

  Returns the bearing to the bullet. If you were to turnRight(e.getBearing()), you would be facing the direction the bullet came from. The calculation used here is: (bullet's heading + Math.PI) - (your heading) -Math.PI < bearing <= Math.PI

  Returns:
    bearing to the bullet.

### getBullet

    public Bullet getBullet()

  Returns the Bullet that hit you.

  Returns:
    Bullet

### getHeading

    public double getHeading()

  Returns the direction the bullet was heading when it hit you, in degrees (0 <= getHeading() < 360) This is not relative to the direction you are facing. The robot that fired this bullet was in the opposite direction of getHeading() when it fired this bullet.

  Returns:
    direction the bullet was heading.

### getHeadingDegrees

    public double getHeadingDegrees()

  Deprecated. use getHeading

### getHeadingRadians

    public double getHeadingRadians()

  Returns the direction the bullet was heading when it hit you, in radians (0 <= getHeading() < 2 * PI) This is not relative to the direction you are facing. The robot that fired this bullet was in the opposite direction of getHeading() when it fired this bullet.

  Returns:
    direction the bullet was heading.

### getName

    public String getName()

  Returns the name of the robot that fired this bullet

  Returns:
    the name of the robot that fired this bullet

### getPower

    public double getPower()

  Returns the power of this bullet. The damage you take (in fact, already took) is 4 * power, plus 2 * (power-1) if power > 1. The robot that fired the bullet receives 3 * power back.

  Returns:
    power of the bullet.

### getVelocity

    public double getVelocity()

  Returns the velocity of this bullet. Currently, this is a constant.

  Returns:
    velocity of the bullet that hit you

Package | Class | Use | Tree | Serialized | Deprecated | Index | Help

PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD