robocode
Class HitRobotEvent
- Comparable
public class HitRobotEvent
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.
- Mathew A. Nelson (original)
HitRobotEvent(String name, double bearing, double energy, boolean atFault) - Called by the game to create a new HitRobotEvent.
|
HitRobotEvent
public HitRobotEvent(String name,
double bearing,
double energy,
boolean atFault)
Called by the game to create a new HitRobotEvent.
name
- the name of the robot you hitbearing
- the bearing to the robot that your robot hit, in radiansenergy
- the amount of energy of the robot you hitatFault
- true
if your robot was moving toward the other
robot; false
otherwise
String getRobotName
public @Deprecated String getRobotName()
Use getName()
instead.
- the name of the robot you hit
double getBearingDegrees
public @Deprecated double getBearingDegrees()
Use getBearing()
instead.
- the bearing to the robot you hit, in degrees
getBearing
public double getBearing()
Returns the bearing to the robot you hit, relative to your robot's
heading, in degrees (-180 <= getBearing() <32180)
- the bearing to the robot you hit, in degrees
getBearingRadians
public double getBearingRadians()
Returns the bearing to the robot you hit, relative to your robot's
heading, in radians (-PI <= getBearingRadians() <32PI)
- the bearing to the robot you hit, in radians
getEnergy
public double getEnergy()
Returns the amount of energy of the robot you hit.
- the amount of energy of the robot you hit
getName
public String getName()
Returns the name of the robot you hit.
- the name of the robot you hit
int compareTo
public @Override int compareTo(Event event)
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
.
true
if your robot was moving towards the robot that was
hit; false
otherwise.