com.b3dgs.lionengine.game
Class Entity

java.lang.Object
  extended by com.b3dgs.lionengine.game.purviews.Configurable
      extended by com.b3dgs.lionengine.game.Entity
All Implemented Interfaces:
Collisionable, Mirrorable
Direct Known Subclasses:
AbstractEntity, AbstractEntry, Projectile

public class Entity
extends Configurable
implements Collisionable, Mirrorable

Main object that can be used by any higher level object for a game. It support external configuration, bounding box collision, and mirror.


Field Summary
protected  Collisionable collisionable
          Collisionable object reference.
protected  int height
          Entity size.
protected  Mirrorable mirrorable
          Mirrorable object reference.
protected  int width
          Entity size.
protected  float x
          Real locations.
protected  float xOld
          Real locations.
protected  float y
          Real locations.
protected  float yOld
          Real locations.
 
Constructor Summary
Entity()
          Create a new blank entity.
Entity(Configurable configurable)
          Create a new entity from an existing configuration.
 
Method Summary
 void backupCoord()
          Save old locations.
 void cancelMirror(boolean state)
          Set cancel state for the mirror operation.
 boolean collide(Entity entity)
          Check if the entity entered in collision with another one.
 boolean collide(java.awt.geom.Rectangle2D area)
          Check if the entity entered in collision with a specified area.
 boolean getCancelMirror()
          Get mirror cancel state.
 java.awt.geom.Rectangle2D getCollision()
          Get collision representation.
 int getHeight()
          Get current height.
 boolean getMirror()
          Get current mirror state.
 java.awt.geom.Line2D getRay()
          Get collision ray cast.
 int getWidth()
          Get current width.
 int getX()
          Get position x.
 float getXOld()
          Get old position x.
 float getXReal()
          Get position x.
 int getY()
          Get position y.
 float getYOld()
          Get old position y.
 float getYReal()
          Get position y.
 void invertYAxis(boolean invert)
          Invert Y axis (recommended in case of platform game.
 void mirror(boolean state)
          Set the next mirror state and apply it on next turn.
 void move(float vx, float vy)
          Move entity using specified vector.
 void place(int x, int y)
          Set location.
 void renderCollision(java.awt.Graphics2D g, Camera camera)
          Render collision bounding box.
 void updateCollision(int x, int y, int width, int height)
          Update collision with specified area.
 void updateMirror()
          Update mirror and apply it if necessary.
 
Methods inherited from class com.b3dgs.lionengine.game.purviews.Configurable
checkInstruction, getAnim, getCollArea, getData, getDataBool, getDataInt, getDataString, getRange, loadData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

collisionable

protected final Collisionable collisionable
Collisionable object reference.


mirrorable

protected final Mirrorable mirrorable
Mirrorable object reference.


x

protected float x
Real locations.


y

protected float y
Real locations.


xOld

protected float xOld
Real locations.


yOld

protected float yOld
Real locations.


width

protected int width
Entity size.


height

protected int height
Entity size.

Constructor Detail

Entity

public Entity()
Create a new blank entity.


Entity

public Entity(Configurable configurable)
Create a new entity from an existing configuration.

Parameters:
configurable - configuration reference.
Method Detail

place

public void place(int x,
                  int y)
Set location.

Parameters:
x - location x.
y - location y.

move

public void move(float vx,
                 float vy)
Move entity using specified vector.

Parameters:
vx - horizontal vector.
vy - vertical vector.

backupCoord

public void backupCoord()
Save old locations. Already called in case of place() and move().


getX

public int getX()
Get position x.

Returns:
position x.

getY

public int getY()
Get position y.

Returns:
position y.

getXReal

public float getXReal()
Get position x.

Returns:
position x.

getYReal

public float getYReal()
Get position y.

Returns:
position y.

getXOld

public float getXOld()
Get old position x.

Returns:
old position x.

getYOld

public float getYOld()
Get old position y.

Returns:
old position y.

getWidth

public int getWidth()
Get current width.

Returns:
current width.

getHeight

public int getHeight()
Get current height.

Returns:
current height.

updateCollision

public void updateCollision(int x,
                            int y,
                            int width,
                            int height)
Description copied from interface: Collisionable
Update collision with specified area.

Specified by:
updateCollision in interface Collisionable
Parameters:
x - horizontal offset from entity.
y - vertical offset from entity.
width - entity collision width.
height - entity collision height.

collide

public boolean collide(Entity entity)
Description copied from interface: Collisionable
Check if the entity entered in collision with another one.

Specified by:
collide in interface Collisionable
Parameters:
entity - opponent.
Returns:
true if collide.

collide

public boolean collide(java.awt.geom.Rectangle2D area)
Description copied from interface: Collisionable
Check if the entity entered in collision with a specified area.

Specified by:
collide in interface Collisionable
Parameters:
area - area to check.
Returns:
true if collide.

invertYAxis

public void invertYAxis(boolean invert)
Description copied from interface: Collisionable
Invert Y axis (recommended in case of platform game.

Specified by:
invertYAxis in interface Collisionable
Parameters:
invert - inversion state.

renderCollision

public void renderCollision(java.awt.Graphics2D g,
                            Camera camera)
Description copied from interface: Collisionable
Render collision bounding box.

Specified by:
renderCollision in interface Collisionable
Parameters:
g - graphics output.
camera - camera reference.

getCollision

public java.awt.geom.Rectangle2D getCollision()
Description copied from interface: Collisionable
Get collision representation.

Specified by:
getCollision in interface Collisionable
Returns:
collision representation.

getRay

public java.awt.geom.Line2D getRay()
Description copied from interface: Collisionable
Get collision ray cast.

Specified by:
getRay in interface Collisionable
Returns:
collision ray cast.

mirror

public void mirror(boolean state)
Description copied from interface: Mirrorable
Set the next mirror state and apply it on next turn.

Specified by:
mirror in interface Mirrorable
Parameters:
state - next mirror state.

updateMirror

public void updateMirror()
Description copied from interface: Mirrorable
Update mirror and apply it if necessary.

Specified by:
updateMirror in interface Mirrorable

cancelMirror

public void cancelMirror(boolean state)
Description copied from interface: Mirrorable
Set cancel state for the mirror operation.

Specified by:
cancelMirror in interface Mirrorable
Parameters:
state - state.

getCancelMirror

public boolean getCancelMirror()
Description copied from interface: Mirrorable
Get mirror cancel state.

Specified by:
getCancelMirror in interface Mirrorable
Returns:
mirror cancel state.

getMirror

public boolean getMirror()
Description copied from interface: Mirrorable
Get current mirror state.

Specified by:
getMirror in interface Mirrorable
Returns:
current mirror state.