AI for Games 1.1.1
|
Classes | |
class | DepthOrder |
Public Member Functions | |
BaseEntity () | |
BaseEntity (String name) | |
BaseEntity (String entityName, Vector2D entityPos, double entityColRadius) | |
int | ID () |
void | updateFSM (double deltaTime, World world) |
FiniteStateMachine | FSM () |
boolean | hasFSM () |
void | addFSM () |
boolean | removeFSM () |
int | Z () |
BaseEntity | Z (int z) |
boolean | isVisible () |
BaseEntity | visible (boolean visible) |
double | colRadius () |
BaseEntity | colRadius (double colRadius) |
boolean | isOverLapAllowed () |
BaseEntity | overLapAllowed (boolean overLapAllowed) |
boolean | isInDomain (Domain view) |
boolean | isOver (double px, double py) |
BaseEntity | renderer (Picture renderer) |
Picture | renderer () |
void | die (World world, double timeToLive) |
void | born (World world, double timeToLive) |
BaseEntity | moveTo (double x, double y) |
BaseEntity | moveTo (Vector2D p) |
BaseEntity | moveBy (double x, double y) |
BaseEntity | moveBy (Vector2D p) |
Vector2D | pos () |
BaseEntity | name (String name) |
String | name () |
boolean | isEitherSide (double x0, double y0, double x1, double y1) |
boolean | isEitherSide (Vector2D p0, Vector2D p1) |
void | update (double deltaTime, World world) |
void | draw (World world) |
void | draw (double elapsedTime, World world) |
int | compareTo (BaseEntity o) |
String | toString () |
Public Attributes | |
String | tag = "" |
int | tagNo = 0 |
Protected Attributes | |
Integer | entityID |
String | name = "" |
Picture | renderer = null |
boolean | visible = true |
Vector2D | pos = new Vector2D() |
double | colRadius |
Package Attributes | |
boolean | overlapAllowed = false |
Private Attributes | |
FiniteStateMachine | fsm = null |
int | z = 0 |
Static Private Attributes | |
static int | nextID = Integer.MIN_VALUE |
This is the base class for all game entities.
game2dai.entities.BaseEntity.BaseEntity | ( | ) |
Default constructor
game2dai.entities.BaseEntity.BaseEntity | ( | String | name | ) |
Constructor will give the entity a unique ID.
name | the name of this entity - default name is used if none provided. |
game2dai.entities.BaseEntity.BaseEntity | ( | String | entityName, |
Vector2D | entityPos, | ||
double | entityColRadius | ||
) |
Constructor will give the entity a unique ID.
entityName | the name of this entity - default name is used if none provided. |
entityPos | the world position for this entity |
entityColRadius | the bounding radius for this entity |
void game2dai.entities.BaseEntity.addFSM | ( | ) |
This is the only way to add a finite state machine to the entity.
void game2dai.entities.BaseEntity.born | ( | World | world, |
double | timeToLive | ||
) |
This is the only safe way to add an entity to the World object once initialisation has
finished and the game/simulation is in play. It does not add the entity directly but schedules it for addition at the start of the world update() method.
During initialisation (i.e. setup) it is recommended that you use the World add(0 method instead.
world | the world to add this entity to |
timeToLive | time left to wait before adding to the world in seconds |
double game2dai.entities.BaseEntity.colRadius | ( | ) |
Get the bounding radius for this object.
BaseEntity game2dai.entities.BaseEntity.colRadius | ( | double | colRadius | ) |
Set the bounding radius for this object
colRadius | the collision radius to set |
int game2dai.entities.BaseEntity.compareTo | ( | BaseEntity | o | ) |
Compare 2 entities based on their entity ID numbers
void game2dai.entities.BaseEntity.die | ( | World | world, |
double | timeToLive | ||
) |
This is the only safe way to remove an entity from the World object. It does not remove the object directly but schedules it for removal at the start of the world update() method.
world | the world to remove this entity in |
timeToLive | time left to stay in the world in seconds |
void game2dai.entities.BaseEntity.draw | ( | double | elapsedTime, |
World | world | ||
) |
DO NOT CALL THIS METHOD DIRECTLY
If this shape has a renderer and is visible call the renderer's draw method passing all appropriate information.
This should be overridden in child classes
Reimplemented in game2dai.entities.MovingEntity.
void game2dai.entities.BaseEntity.draw | ( | World | world | ) |
DO NOT CALL THIS METHOD DIRECTLY
This method is left to ensure backward compatibility with library versions prior to 1.0
Use the draw(elapsedTime, world) method instead.
This should be overridden in child classes
Reimplemented in game2dai.entities.MovingEntity.
FiniteStateMachine game2dai.entities.BaseEntity.FSM | ( | ) |
Returns a reference to the entity's finite state machine or null if there is no FSM
boolean game2dai.entities.BaseEntity.hasFSM | ( | ) |
Does this entity have a finite state machine
int game2dai.entities.BaseEntity.ID | ( | ) |
Get the entity's unique ID number
boolean game2dai.entities.BaseEntity.isEitherSide | ( | double | x0, |
double | y0, | ||
double | x1, | ||
double | y1 | ||
) |
Determines whether the two points given are 'either side of the object' if true then the two positions are not visible to each other.
This should be overridden in child classes.
x0 | x position of first point of interest |
y0 | y position of first point of interest |
x1 | x position of second point of interest |
y1 | y position of second point of interest |
Reimplemented in game2dai.entities.Building, game2dai.entities.MovingEntity, game2dai.entities.Obstacle, and game2dai.entities.Wall.
Determines whether the two points given are 'either side of the object' if true then the two positions are not visible to each other.
This should be overridden in child classes.
p0 | first point of interest |
p1 | second point of interest |
boolean game2dai.entities.BaseEntity.isInDomain | ( | Domain | view | ) |
Determine whether this entity is inside or part inside the domain. This method is used by the world draw method to see if this entity should be drawn.
view | the world domain |
Reimplemented in game2dai.entities.Artefact, game2dai.entities.Building, game2dai.entities.MovingEntity, game2dai.entities.Obstacle, and game2dai.entities.Wall.
boolean game2dai.entities.BaseEntity.isOver | ( | double | px, |
double | py | ||
) |
Determine whether the given world position is over a given entity.
px | x position of point of interest |
py | y position of point of interest |
Reimplemented in game2dai.entities.Building, game2dai.entities.MovingEntity, game2dai.entities.Obstacle, and game2dai.entities.Wall.
boolean game2dai.entities.BaseEntity.isOverLapAllowed | ( | ) |
Should this entity be considered if the world is enforcing the no-overlap rule.
boolean game2dai.entities.BaseEntity.isVisible | ( | ) |
Is this entity visible
BaseEntity game2dai.entities.BaseEntity.moveBy | ( | double | x, |
double | y | ||
) |
Move the current position for this entity by the specified amount.
x | world x distance to move |
y | world y distance to move |
BaseEntity game2dai.entities.BaseEntity.moveBy | ( | Vector2D | p | ) |
Move the current position for this entity by the specified amount.
p | the vector to move by |
BaseEntity game2dai.entities.BaseEntity.moveTo | ( | double | x, |
double | y | ||
) |
Set the current position for this entity.
x | world x position |
y | world y position |
BaseEntity game2dai.entities.BaseEntity.moveTo | ( | Vector2D | p | ) |
Set the current position for this entity.
p | the position to set |
String game2dai.entities.BaseEntity.name | ( | ) |
Get the current name of the entity.
BaseEntity game2dai.entities.BaseEntity.name | ( | String | name | ) |
Change the name of this entity
name | the new name to use |
BaseEntity game2dai.entities.BaseEntity.overLapAllowed | ( | boolean | overLapAllowed | ) |
Set whether the entity should be considered when (and if) the world is enforcing the no overLap rule.
overLapAllowed |
Vector2D game2dai.entities.BaseEntity.pos | ( | ) |
Get the current position.
boolean game2dai.entities.BaseEntity.removeFSM | ( | ) |
This is the only way to remove a FSM once added. The FSM is always removed,
Picture game2dai.entities.BaseEntity.renderer | ( | ) |
Get the render object. This is useful if you want to change how an object is drawn during a game. In most cases you will have to cast it to the appropriate type before using it.
BaseEntity game2dai.entities.BaseEntity.renderer | ( | Picture | renderer | ) |
Add a render object to this entity. This is essential if you want to display the entity.
Assumes that if the parameter is not null then you want to see this entity. If you don't then
renderer | the renderer to use (it must implement Renderer) |
String game2dai.entities.BaseEntity.toString | ( | ) |
Entity ID number and name returned as a String
Reimplemented in game2dai.entities.Building, game2dai.entities.Obstacle, and game2dai.entities.Vehicle.
void game2dai.entities.BaseEntity.update | ( | double | deltaTime, |
World | world | ||
) |
The main update method for an entity. This method will be called by the world update method if the entity has been 'added' to the world.
deltaTime | elapsed time since last update |
world | the game world object |
Reimplemented in game2dai.entities.MovingEntity, and game2dai.entities.Vehicle.
void game2dai.entities.BaseEntity.updateFSM | ( | double | deltaTime, |
World | world | ||
) |
If this entity has a state machine then call its update method.
deltaTime | elapsed time since last update (seconds) |
world | the game world object |
BaseEntity game2dai.entities.BaseEntity.visible | ( | boolean | visible | ) |
Set the entity's visibility
visible | true or false |
int game2dai.entities.BaseEntity.Z | ( | ) |
Get the draw order depth.
BaseEntity game2dai.entities.BaseEntity.Z | ( | int | z | ) |
Set the draw order depth. The greater the value of z the closer it is to the viewer.
z | the z to set |
String game2dai.entities.BaseEntity.tag = "" |
The tag attribute is not used by the library code. It is there for the user to use in any way they wish.
When the entity is created it is initialised to
"Entity <i>entityID</i>"
<br<blockquote>
Where entityID is the unique id created by the library for this entity.
int game2dai.entities.BaseEntity.tagNo = 0 |
The tagNo attribute is not used by the library code. It is there for the user to use in any way they wish.