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

## robocode
Class HitRobotEvent

    java.lang.Object
      robocode.Event
          robocode.HitRobotEvent

All Implemented Interfaces:
  java.lang.Comparable<Event>

    public class HitRobotEvent

extends Event

A HitRobotEvent is sent to `onHitRobot` when your robot collides with another robot. You can use the information contained in this event to determine what to do.

Author:
  Mathew A. Nelson (original)

Constructor Summary
`HitRobotEvent(java.lang.String name, double bearing, double energy, boolean atFault)` Called by the game to create a new HitRobotEvent.

Method Summary
`double` | `getBearing()` Returns the bearing to the robot you hit, relative to your robot's heading, in degrees (-180 <= getBearing() < 180)
`double` | `getBearingDegrees()` Deprecated. Use `getBearing()` instead.
`double` | `getBearingRadians()` Returns the bearing to the robot you hit, relative to your robot's heading, in radians (-PI <= getBearingRadians() < PI)
`double` | `getEnergy()` Returns the amount of energy of the robot you hit.
`java.lang.String` | `getName()` Returns the name of the robot you hit.
`java.lang.String` | `getRobotName()` Deprecated. Use `getName()` instead.
`boolean` | `isMyFault()` Checks if your robot was moving towards the robot that was hit.

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

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

Constructor Detail

### HitRobotEvent

    public HitRobotEvent(java.lang.String name,
                         double bearing,
                         double energy,
                         boolean atFault)

  Called by the game to create a new HitRobotEvent.

  Parameters:
    `name` - the name of the robot you hit
    `bearing` - the bearing to the robot that your robot hit, in radians
    `energy` - the amount of energy of the robot you hit
    `atFault` - `true` if your robot was moving toward the other robot; `false` otherwise

Method Detail

### getBearing

    public double getBearing()

  Returns the bearing to the robot you hit, relative to your robot's heading, in degrees (-180 <= getBearing() < 180)

  Returns:
    the bearing to the robot you hit, in degrees

### getBearingDegrees

    @Deprecated
    public double getBearingDegrees()

  Deprecated. Use `getBearing()` instead.

### getBearingRadians

    public double getBearingRadians()

  Returns the bearing to the robot you hit, relative to your robot's heading, in radians (-PI <= getBearingRadians() < PI)

  Returns:
    the bearing to the robot you hit, in radians

### getEnergy

    public double getEnergy()

  Returns the amount of energy of the robot you hit.

  Returns:
    the amount of energy of the robot you hit

### getName

    public java.lang.String getName()

  Returns the name of the robot you hit.

  Returns:
    the name of the robot you hit

### getRobotName

    @Deprecated
    public java.lang.String getRobotName()

  Deprecated. Use `getName()` instead.

### isMyFault

    public boolean isMyFault()

  Checks if your robot was moving towards the robot that was hit.

  If isMyFault() returns `true` then your robot's movement (including turning) will have stopped and been marked complete.

  Note: If two robots are moving toward each other and collide, they will each receive two HitRobotEvents. The first will be the one if isMyFault() returns `true`.

  Returns:
    `true` if your robot was moving towards the robot that was hit; `false` otherwise.

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