public class GraphicEntityModule extends java.lang.Object implements Module
Use it by creating shapes, sprites, texts etc, then commiting their states to a certain moment of the frame. By default, the states are commited automatically at the end of the frame.
Modifier and Type | Method and Description |
---|---|
void |
commitEntityState(double t,
Entity<?>... entities)
This entity's graphical counterpart, at instant t of the frame being computed, will have the same properties as the java object as it is now.
|
void |
commitWorldState(double t)
Every entity's graphical counterpart, at instant t of the frame being computed, will have the same properties as the java object as they are
now.
|
Circle |
createCircle()
Creates a new Circle entity, its graphical counterpart will be created on the frame currently being computed.
|
Group |
createGroup(Entity<?>... entities)
Creates a new Group entity, its graphical counterpart will be created on the frame currently being computed.
|
Line |
createLine()
Creates a new Line entity, its graphical counterpart will be created on the frame currently being computed.
|
Rectangle |
createRectangle()
Creates a new Rectangle entity, its graphical counterpart will be created on the frame currently being computed.
|
Sprite |
createSprite()
Creates a new Sprite entity, its graphical counterpart will be created on the frame currently being computed.
|
SpriteAnimation |
createSpriteAnimation()
Creates a new Sprite animation, its graphical counterpart will be created on the frame currently being computed.
|
Text |
createText(java.lang.String string)
Creates a new Text entity, its graphical counterpart will be created on the frame currently being computed.
|
World |
createWorld(int width,
int height)
Creates a new world data object to be used to compute all frames throughout the game.
|
World |
getWorld() |
void |
onAfterGameTurn()
Called by the game manager after calling the
Referee 's gameTurn method. |
void |
onAfterOnEnd()
Called by the game manager after calling the
Referee 's onEnd method. |
void |
onGameInit()
Called by the game manager after calling the
Referee 's init method. |
public World createWorld(int width, int height)
This method may only be called once. This method may not be called after the frames have started being computed.
The world's width and height determine how the positions of all entities are mapped onto the viewer.
width
- The number of units across the width of the visible part of the game. Default is 1920.height
- The number of units across the height of the visible part of the game. Default is 1080.java.lang.IllegalStateException
- if the method is called more than once or after the game begins.public World getWorld()
public void commitWorldState(double t)
Only the most recent commits are kept for a given t.
If an entity hasn't changed since its previous commit, its commit is ignored.
t
- The instant of the frame 0 ≥ t ≥ 1.java.lang.IllegalArgumentException
- if the t is not a valid instant.public void commitEntityState(double t, Entity<?>... entities)
Only the most recent commit is kept for a given t.
If the entity hasn't changed since its previous commit, the commit is ignored.
t
- The instant of the frame 0 ≥ t ≥ 1.entities
- The entity objects to commit.java.lang.IllegalArgumentException
- if the t is not a valid instant or id entities is empty.public Circle createCircle()
public Sprite createSprite()
public Line createLine()
public Rectangle createRectangle()
public Text createText(java.lang.String string)
string
- The default string for the text. Can be changed.public Group createGroup(Entity<?>... entities)
A Group represents a collection of other entities. It acts as a container.
entities
- 0 or more entities to immediately add to this group.public SpriteAnimation createSpriteAnimation()
public final void onGameInit()
Module
Referee
's init method.
The module must be registered to the game manager.onGameInit
in interface Module
public final void onAfterGameTurn()
Module
Referee
's gameTurn method.
The module must be registered to the game manager.onAfterGameTurn
in interface Module
public final void onAfterOnEnd()
Module
Referee
's onEnd method.
The module must be registered to the game manager.onAfterOnEnd
in interface Module