public final class HitByBulletEvent extends Event
onHitByBullet()
when your robot has been hit by a bullet.
You can use the information contained in this event to determine what to do.Constructor and Description |
---|
HitByBulletEvent(double bearing,
Bullet bullet)
Called by the game to create a new HitByBulletEvent.
|
Modifier and Type | Method and Description |
---|---|
double |
getBearing()
Returns the bearing to the bullet, relative to your robot's heading,
in degrees (-180 < getBearing() <= 180).
|
double |
getBearingRadians()
Returns the bearing to the bullet, relative to your robot's heading,
in radians (-Math.PI < getBearingRadians() <= Math.PI).
|
Bullet |
getBullet()
Returns the bullet that hit your robot.
|
double |
getHeading()
Returns the heading of the bullet when it hit you, in degrees
(0 <= getHeading() < 360).
|
double |
getHeadingDegrees()
Deprecated.
Use
getHeading() instead. |
double |
getHeadingRadians()
Returns the heading of the bullet when it hit you, in radians
(0 <= getHeadingRadians() < 2 * PI).
|
String |
getName()
Returns the name of the robot that fired the bullet.
|
double |
getPower()
Returns the power of this bullet.
|
double |
getVelocity()
Returns the velocity of this bullet.
|
compareTo, getPriority, getTime, setPriority, setTime
public HitByBulletEvent(double bearing, Bullet bullet)
bearing
- the bearing of the bullet that hit your robot, in radiansbullet
- the bullet that has hit your robotpublic double getBearing()
If you were to turnRight(event.getBearing()), you would be facing the direction the bullet came from. The calculation used here is: (bullet's heading in degrees + 180) - (your heading in degrees)
public double getBearingRadians()
If you were to turnRightRadians(event.getBearingRadians()), you would be facing the direction the bullet came from. The calculation used here is: (bullet's heading in radians + Math.PI) - (your heading in radians)
public Bullet getBullet()
public double getHeading()
Note: This is not relative to the direction you are facing. The robot that fired the bullet was in the opposite direction of getHeading() when it fired the bullet.
@Deprecated public double getHeadingDegrees()
getHeading()
instead.public double getHeadingRadians()
Note: This is not relative to the direction you are facing. The robot that fired the bullet was in the opposite direction of getHeadingRadians() when it fired the bullet.
public String getName()
public double getPower()
public double getVelocity()
Copyright © 2021 Robocode. All Rights Reserved.