public class Ship extends Entity
minRadiusBlackHole, minRadiusBullet, minRadiusMinorPlanet, minRadiusShip, position, radius, velocity
Constructor and Description |
---|
Ship(double positionX,
double positionY,
double velocityX,
double velocityY,
double radius,
double angle,
double mass)
Initialize a ship with x-position, y-position, velocity in x-direction, velocity in y-direction, angle, radius.
|
Modifier and Type | Method and Description |
---|---|
void |
collide(Entity other)
Resolve the collision of a ship with another entity.
|
java.util.List<java.lang.Object> |
executeProgram(double duration)
Execute the program for a given duration.
|
void |
fireBullet()
Fire a bullet from the ship.
|
double |
getAcceleration()
Return the acceleration of the ship.
|
double |
getAngle()
Return the angle (orientation) of this ship.
|
java.util.Set<Bullet> |
getBullets()
Return the bullets loaded onto this ship.
|
double |
getMass()
Return the total mass of the ship.
|
Program |
getProgram()
Get the program loaded on this ship.
|
boolean |
isThrusterEnabled()
Return the condition of the thruster.
|
boolean |
isValidBullet(Bullet bullet)
Return true if given bullet is not loaded on ship.
|
void |
loadBullet(Bullet bullet)
Load the given bullet onto the ship.
|
void |
loadSetOfBullets(java.util.Collection<Bullet> bullets)
Load a set of bullets onto the ship.
|
void |
move(double duration)
Move the ship for a given amount of time.
|
void |
removeBulletShip(Bullet bullet)
Remove given bullet from ship.
|
void |
setMass(double mass)
Set the mass of this ship to the given mass.
|
void |
setProgram(Program program)
Set the program of this ship to the given program.
|
void |
teleportShip()
Teleport ship to a random location.
|
void |
thrust(double amount)
Method to increase (or decrease) the velocity of this ship.
|
void |
thrustOff()
Reset condition of the thruster.
|
void |
thrustOn()
Set thruster condition active.
|
void |
turn(double angle)
Turn the ship by adding a given angle to the current orientation.
|
bounceOffEntity, collideWithBoundary, getCollisionPositionWithBoundary, getDistanceBetween, getDistanceBetweenCenters, getMinRadius, getMinShipMass, getMovementPrediction, getPosition, getPositionCollisionWithEntity, getRadius, getSpeedOfLight, getTimeCollisionWithEntity, getTimeCollisionWithShip, getTimeToCollisionWithBoundary, getTotalVelocity, getVelocity, getWorld, isInRange, isTerminated, isValidRadius, overlap, removeWorld, setPosition, setRadius, setVelocity, setWorld, terminate
public Ship(double positionX, double positionY, double velocityX, double velocityY, double radius, double angle, double mass) throws java.lang.IllegalArgumentException
positionX
- The x-coordinate of this new ship.positionY
- The y-coordinate of this new ship.velocityX
- The velocity in the x-direction of this new ship.velocityY
- The velocity in the y-direction of this new ship.angle
- The angle (orientation) which this new ship is facing in.radius
- The radius of this new ship.mass
- The mass of this new ship.java.lang.IllegalArgumentException
public double getAngle()
public void thrust(double amount)
amount
- The amount of velocity that needs to be added to the current velocity.public void turn(double angle)
angle
- The given angle that has to be added to the current angle.public void thrustOn()
public void thrustOff()
public boolean isThrusterEnabled()
public double getAcceleration()
public void move(double duration)
public void collide(Entity other)
public void setMass(double mass)
mass
- The given mass.public double getMass()
public java.util.Set<Bullet> getBullets()
public void loadBullet(Bullet bullet) throws java.lang.IllegalArgumentException
bullet
- Bullet to load onto the ship.java.lang.IllegalArgumentException
- Bullet is already loaded onto the ship.public void loadSetOfBullets(java.util.Collection<Bullet> bullets) throws java.lang.IllegalArgumentException
bullets
- Bullets to load onto the ship.java.lang.IllegalArgumentException
- Bullet is already loaded onto the ship.public boolean isValidBullet(Bullet bullet)
bullet
- The given bullet.public void teleportShip()
public void removeBulletShip(Bullet bullet) throws java.lang.IllegalArgumentException
bullet
- The bullet to remove.java.lang.IllegalArgumentException
public void fireBullet()
public void setProgram(Program program)
program
- The given program.public Program getProgram()
public java.util.List<java.lang.Object> executeProgram(double duration)