|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrobocode.Event
robocode.HitByBulletEvent
public class HitByBulletEvent
A HitByBulletEvent is sent to 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 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, relative to your robot's heading, in degrees (-180 < getBearing() <= 180) If you were to turnRight(e.getBearing()), you would be facing the direction the bullet came from. |
double |
getBearingRadians()
Returns the bearing to the bullet, relative to your robot's heading, in radians (-Math.PI < getBearingRadians() <= Math.PI) If you were to turnRightRadians(e.getBearingRadians()), you would be facing the direction the bullet came from. |
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) Note: This is not relative to the direction you are facing. |
double |
getHeadingDegrees()
Deprecated. Use getHeading() instead. |
double |
getHeadingRadians()
Returns the heading of the bullet when it hit you, in radians (0 <= getHeadingRadians() < 2 * PI) Note: This is not relative to the direction you are facing. |
java.lang.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. |
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 |
---|
public HitByBulletEvent(double bearing, Bullet bullet)
bearing
- the bearing of the bullet that hit your robot, in radiansbullet
- the bullet that has hit your robotMethod Detail |
---|
public double getBearing()
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 in degrees + 180) - (your heading in degrees)
public double getBearingRadians()
If you were to turnRightRadians(e.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 java.lang.String getName()
public double getPower()
public double getVelocity()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |