HitRobotEvent

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 HitRobotEvent

    java.lang.Object
      robocode.Event
          robocode.HitRobotEvent

All Implemented Interfaces:
  Comparable

public class HitRobotEvent
extends Event

A HitRobotEvent is sent to `Robot.onHitRobot(robocode.HitRobotEvent)` when you collide with another robot You can use the information contained in this event to determine what to do.

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

Method Summary
`double` | `getBearing()` Returns the angle to the robot you hit, relative to your robot's heading.
`double` | `getBearingDegrees()` Deprecated. use getBearing
`double` | `getBearingRadians()` Returns the angle to the robot you hit in radians, relative to your robot's heading.
`double` | `getEnergy()` Returns the energy of the robot you hit
`String` | `getName()` Returns the name of the robot you hit
`String` | `getRobotName()` Deprecated. use getName
`boolean` | `isMyFault()` If you were moving toward the robot you hit, isMyFault() will return true.

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

### HitRobotEvent

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

  Called by the game to create a new HitRobotEvent.

Method Detail

### getBearing

    public double getBearing()

  Returns the angle to the robot you hit, relative to your robot's heading. -180 <= getBearing() < 180

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

### getBearingDegrees

    public double getBearingDegrees()

  Deprecated. use getBearing

### getBearingRadians

    public double getBearingRadians()

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

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

### getEnergy

    public double getEnergy()

  Returns the energy of the robot you hit

  Returns:
    the energy of the robot you hit

### getName

    public String getName()

  Returns the name of the robot you hit

  Returns:
    the name of the robot you hit

### getRobotName

    public String getRobotName()

  Deprecated. use getName

### isMyFault

    public boolean isMyFault()

  If you were moving toward the robot you hit, isMyFault() will return true. If isMyFault() is 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 with isMyFault() == true.

  Returns:
    whether or not you were moving toward the other robot.

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

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