public class World
extends java.lang.Object
Constructor and Description |
---|
World(double width,
double height)
Initaliaze a world with width and height.
|
Modifier and Type | Method and Description |
---|---|
void |
addEntity(Entity entity)
Add the given entity to the world.
|
boolean |
entityOutOfBounds(Entity entity)
Return true if the entity is out of bounds.
|
void |
evolve(double duration,
asteroids.part2.CollisionListener collisionListener)
Method to evolve the world during a given duration.
|
Entity |
getEntityAtPosition(double x,
double y)
Return the entity, if any, at the given x- and y-coordinate.
|
java.util.Set<Entity> |
getEntitySet()
Return the set of Entities of this world.
|
double |
getHeight()
Returning this world's height.
|
Entity[] |
getNextCollidingEntities()
Method that returns the entities involved in the next collision.
|
double[] |
getNextCollisionPosition()
Method that returns the position of the next collision.
|
double |
getTimeNextCollision()
Return the time until the next collision occurs in this world, if 2 entities overlap, return 0.
|
double |
getWidth()
Returning this world's width.
|
boolean |
isTerminated()
Return the status of this world.
|
boolean |
isValidEntity(Entity entity)
Return true if the entity is valid for this world.
|
void |
removeEntity(Entity entity)
Remove the given entity from the world.
|
void |
setHeight(double height)
Set the height of this world with the given height.
|
void |
setWidth(double width)
Set the width of this world with the given width.
|
void |
terminateWorld()
Terminate the world by removing all of its entities.
|
public World(double width, double height)
width
- The width of the world.height
- The height of the world.public void setWidth(double width)
width
- The given width for this world.public void setHeight(double height)
height
- The given height for this world.public double getWidth()
public double getHeight()
public void addEntity(Entity entity) throws java.lang.IllegalArgumentException
entity
- The entity to add.java.lang.IllegalArgumentException
- The entity is already in the world.public void removeEntity(Entity entity) throws java.lang.IllegalArgumentException
entity
- Entity to remove.java.lang.IllegalArgumentException
public boolean entityOutOfBounds(Entity entity)
entity
- The given entity to evaluate.implementation
public java.util.Set<Entity> getEntitySet()
public void terminateWorld()
public boolean isTerminated()
public Entity getEntityAtPosition(double x, double y)
x
- Given x-coordinate.y
- Given y-coordinate.public boolean isValidEntity(Entity entity)
entity
- The given entity to evaluate.implementation
public void evolve(double duration, asteroids.part2.CollisionListener collisionListener) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public double getTimeNextCollision()
implementation
public double[] getNextCollisionPosition()
public Entity[] getNextCollidingEntities()
implementation