public class Bullet extends Entity
Modifier and Type | Field and Description |
---|---|
double |
numberOfBounces
Variable holding the amount of bounces until destruction of this bullet.
|
minRadiusBlackHole, minRadiusBullet, minRadiusMinorPlanet, minRadiusShip, position, radius, velocity
Constructor and Description |
---|
Bullet(double x,
double y,
double velocityX,
double velocityY,
double radius)
Initialize a bullet with x-position, y-position, velocity in x-direction, velocity in y-direction, radius.
|
Modifier and Type | Method and Description |
---|---|
void |
bounce()
Decrements the number of bounces until destruction
|
void |
collide(Entity other)
Resolve collisions between a bullet and another entity.
|
void |
collideWithBoundary()
COLLISION RELATED
|
Ship |
getBulletSource()
Return the source of the fired bullet as a Ship.
|
double |
getNumberOfBouncesLeft()
Returns the number of bounces left until destruction of this bullet.
|
Ship |
getShip()
Return the ship to which the current bullet is attached to.
|
void |
resetBounces()
Set the number of bounces back to 2.
|
void |
setBulletsource(Ship ship)
Set the source of the fired bullet to the given ship
|
void |
setShip(Ship ship)
Sets the ship of the current bullet to the given ship.
|
void |
terminate()
Method to terminate a bullet.
|
bounceOffEntity, getCollisionPositionWithBoundary, getDistanceBetween, getDistanceBetweenCenters, getMass, getMinRadius, getMinShipMass, getMovementPrediction, getPosition, getPositionCollisionWithEntity, getRadius, getSpeedOfLight, getTimeCollisionWithEntity, getTimeCollisionWithShip, getTimeToCollisionWithBoundary, getTotalVelocity, getVelocity, getWorld, isInRange, isTerminated, isValidRadius, move, overlap, removeWorld, setPosition, setRadius, setVelocity, setWorld
public double numberOfBounces
public Bullet(double x, double y, double velocityX, double velocityY, double radius) throws java.lang.IllegalArgumentException
positionX
- The x-coordinate of this new bullet.positionY
- The y-coordinate of this new bullet.velocityX
- The velocity in the x-direction of this new bullet.velocityY
- The velocity in the y-direction of this new bullet.radius
- The radius of this new bullet.java.lang.IllegalArgumentException
public void setShip(Ship ship)
ship
- public Ship getShip()
public Ship getBulletSource()
public void setBulletsource(Ship ship)
public void bounce()
public double getNumberOfBouncesLeft()
public void resetBounces()
public void collideWithBoundary()
collideWithBoundary
in class Entity
public void terminate()