public abstract class Entity
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
double |
minRadiusBlackHole
Constant holding the minimum radius of a BlackHole.
|
double |
minRadiusBullet
Constant holding the minimum radius of a bullet.
|
double |
minRadiusMinorPlanet
Constant holding the minimum radius of a MinorPlanet.
|
double |
minRadiusShip
Constant holding the minimum radius of a ship.
|
Vector |
position |
double |
radius
VARIABLES ENTITY
|
Vector |
velocity |
Constructor and Description |
---|
Entity(double x,
double y,
double velocityX,
double velocityY,
double radius)
Initialize a new entity with x-position, y-position, velocity in x-direction, velocity in y-direction, radius.
|
Modifier and Type | Method and Description |
---|---|
void |
bounceOffEntity(Entity other)
Resolve the bouncing of this entity with another given entity.
|
abstract void |
collide(Entity other) |
void |
collideWithBoundary()
Method executing the change in velocity in order to resolve a collision with a boundary.
|
double[] |
getCollisionPositionWithBoundary()
Method returning a pair of coordinates that represent the location of collision between an entity and a boundary.
|
double |
getDistanceBetween(Entity other)
Compute the distance between two entities.
|
double |
getDistanceBetweenCenters(Entity other)
Method getting returning the distance between the centers of two entitues
|
double |
getMass()
Return the mass of the entity.
|
double |
getMinRadius()
Return the minimun radius of the entity.
|
double |
getMinShipMass()
Get the minimum mass a ship must have.
|
double[] |
getMovementPrediction(double t) |
Vector |
getPosition()
POSITION RELATED
|
double[] |
getPositionCollisionWithEntity(Entity other)
Method returning the position of the collision between this and another entity
|
double |
getRadius()
Return the radius of this entity.
|
static double |
getSpeedOfLight() |
double |
getTimeCollisionWithEntity(Entity entity2)
Method returning the time until a collision happens between this entity and entity2
|
double |
getTimeCollisionWithShip(Ship ship2)
Method returning the time until a collision happens between this entity and ship2
|
double |
getTimeToCollisionWithBoundary()
Method returning the time until THE FIRST collision that happens between this entity and a boundary.
|
double |
getTotalVelocity()
Method computing the total velocity of this entity following the given formula.
|
Vector |
getVelocity()
Returning this entity's velocity
|
World |
getWorld()
Return this entities world.
|
boolean |
isInRange(Entity other)
Check whether entity is in range of another entity or not.
|
boolean |
isTerminated()
Return true if this entity's status (if it's already terminated or not)
|
boolean |
isValidRadius(double radius)
Return if the given radius is a valid radius for this entity.
|
void |
move(double duration)
Move the entity for a certain amount of time (duration).
|
boolean |
overlap(Entity other)
Check if two entities overlap.
|
void |
removeWorld()
Remove the world this entity is part of.
|
void |
setPosition(Vector positionXY)
Set the position of this entity to the given position.
|
void |
setRadius(double radius) |
void |
setVelocity(Vector velocity)
Set the velocity of this entity to the given velocity.
|
void |
setWorld(World world)
Set the world of this entity to the given world.
|
void |
terminate()
Terminate the entity.
|
public double radius
public Vector position
public Vector velocity
public double minRadiusShip
public double minRadiusBullet
public double minRadiusMinorPlanet
public double minRadiusBlackHole
public Entity(double x, double y, double velocityX, double velocityY, double radius) throws java.lang.IllegalArgumentException
x
- The x-coordinate of this new entity.y
- The y-coordinate of this new entity.velocityX
- The velocity in the x-direction of this new entity.velocityY
- The velocity in the y-direction of this new entity.radius
- The radius of this new entity.java.lang.IllegalArgumentException
public Vector getPosition()
public void setPosition(Vector positionXY) throws java.lang.IllegalArgumentException
positionXY
- the given position as a vectorjava.lang.IllegalArgumentException
- Throw exception is position is not valid.public Vector getVelocity()
public void setVelocity(Vector velocity)
velocity
- the given velocity as a vector.public double getTotalVelocity()
public static double getSpeedOfLight()
@Basic @Raw public double getRadius()
public boolean isValidRadius(double radius)
radius
- The given radius.
// * @see implementationpublic void setRadius(double radius)
radius
- public double getMinRadius()
public void move(double duration)
duration
- The amount of time to move.java.lang.IllegalArgumentException
- The duration is less than zero.public double getMass()
public double getMinShipMass()
public void setWorld(World world)
world
- The given world.public World getWorld()
public void removeWorld()
public void terminate()
public boolean isTerminated()
public double getTimeToCollisionWithBoundary()
public double[] getCollisionPositionWithBoundary()
public double[] getMovementPrediction(double t)
public void collideWithBoundary()
public double getTimeCollisionWithEntity(Entity entity2)
entity2
- the entity this entity is colliding withjava.lang.IllegalArgumentException
- | if entity 2 == null
| entity2 does not existpublic double[] getPositionCollisionWithEntity(Entity other)
other
- the entity this entity is colliding withpublic double getTimeCollisionWithShip(Ship ship2)
ship2
- the entity this entity is colliding withjava.lang.IllegalArgumentException
- | if ship2 == null
| ship2 does not existpublic boolean overlap(Entity other)
other
- | Second entitypublic double getDistanceBetween(Entity other)
other
- | Second entity//TODOpublic double getDistanceBetweenCenters(Entity other)
other
- | second entitypublic void bounceOffEntity(Entity other)
other
- The other entity.public abstract void collide(Entity other)
public boolean isInRange(Entity other)
other
- The other entity.
// * @see implementation