AI for Games 1.1.1
Loading...
Searching...
No Matches
game2dai.entities.Vehicle Class Reference
Inheritance diagram for game2dai.entities.Vehicle:

Public Member Functions

 Vehicle (Vector2D position, double radius, Vector2D velocity, double max_speed, Vector2D heading, double mass, double max_turn_rate, double max_force)
 
 Vehicle (String name, Vector2D position, double radius, Vector2D velocity, double max_speed, Vector2D heading, double mass, double max_turn_rate, double max_force)
 
Vehicle AP (AutoPilot ap)
 
AutoPilot AP ()
 
double maxForce ()
 
Vehicle forceRecorderOn ()
 
Vehicle forceRecorderOff ()
 
ForceRecorder forceRecorder ()
 
boolean hasForceRecorder ()
 
void printForceData ()
 
void update (double deltaTime, World world)
 
String toString ()
 
- Public Member Functions inherited from game2dai.entities.MovingEntity
 MovingEntity (Vector2D position, double radius, Vector2D velocity, double max_speed, Vector2D heading, double mass, double max_turn_rate, double max_force)
 
 MovingEntity (String name, Vector2D position, double radius, Vector2D velocity, double max_speed, Vector2D heading, double mass, double max_turn_rate, double max_force)
 
Vector2D prevPos ()
 
Vector2D velocity ()
 
MovingEntity velocity (Vector2D newVel)
 
MovingEntity velocity (double vx, double vy)
 
MovingEntity heading (Vector2D h)
 
MovingEntity heading (double x, double y)
 
Vector2D heading ()
 
Vector2D headingAtRest ()
 
MovingEntity headingAtRest (Vector2D restHeading)
 
void mass (double mass)
 
double mass ()
 
Vector2D side ()
 
double maxSpeed ()
 
MovingEntity maxSpeed (double maxSpeed)
 
double maxForce ()
 
MovingEntity maxForce (double mf)
 
boolean isSpeedMaxedOut ()
 
double speed ()
 
double speedSq ()
 
double maxTurnRate ()
 
MovingEntity maxTurnRate (double maxTurnRate)
 
double turnRate ()
 
MovingEntity turnRate (double turnRate)
 
double viewDistance ()
 
MovingEntity viewDistance (double viewDistance)
 
double viewFOV ()
 
MovingEntity viewFOV (double viewFOV)
 
MovingEntity viewFactors (double viewDistance, double viewFOV)
 
MovingEntity worldDomain (Domain wd)
 
MovingEntity worldDomain (Domain wd, int constraint)
 
MovingEntity worldDomainConstraint (int constraint)
 
Domain worldDomain ()
 
int worldDomainConstraint ()
 
boolean isEitherSide (double x0, double y0, double x1, double y1)
 
boolean canSee (World world, double x0, double y0)
 
boolean canSee (World world, Vector2D pos)
 
boolean rotateHeadingToFacePosition (double deltaTime, Vector2D faceTarget)
 
boolean rotateHeadingToAlignWith (double deltaTime, final Vector2D allignTo)
 
boolean isInDomain (Domain view)
 
boolean isOver (double px, double py)
 
void update (double deltaTime, World world)
 
void draw (double elapsedTime, World world)
 
void draw (World world)
 
- Public Member Functions inherited from game2dai.entities.BaseEntity
 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 ()
 

Static Public Member Functions

static Vehicle[] makeFromXML (PApplet app, String xmlFilename)
 
static Vehicle[] makeFromXML (String xmlFilename)
 
static Vehicle[] makeFromXML (File xmlFile)
 

Protected Attributes

Vector2D force = new Vector2D()
 
Vector2D accel = new Vector2D()
 
ForceRecorder forceRecorder = null
 
- Protected Attributes inherited from game2dai.entities.MovingEntity
Domain wd = null
 
int domainConstraint = SBF.WRAP
 
Vector2D prevPos = new Vector2D()
 
Vector2D velocity = new Vector2D()
 
Vector2D heading = new Vector2D()
 
Vector2D side = new Vector2D()
 
double mass
 
double maxSpeed
 
double maxForce
 
double maxTurnRate
 
double currTurnRate
 
double prevTurnRate
 
double viewDistance = 50
 
double viewFOV = 1.047
 
- Protected Attributes inherited from game2dai.entities.BaseEntity
Integer entityID
 
String name = ""
 
Picture renderer = null
 
boolean visible = true
 
Vector2D pos = new Vector2D()
 
double colRadius
 

Private Attributes

AutoPilot ap
 

Additional Inherited Members

- Public Attributes inherited from game2dai.entities.BaseEntity
String tag = ""
 
int tagNo = 0
 
- Protected Member Functions inherited from game2dai.entities.MovingEntity
void applyDomainConstraint ()
 
- Package Attributes inherited from game2dai.entities.BaseEntity
boolean overlapAllowed = false
 

Detailed Description

This class models the behaviour of a moving entity acting under the influence of an AutoPilot.

Author
Peter Lager

Constructor & Destructor Documentation

◆ Vehicle() [1/2]

game2dai.entities.Vehicle.Vehicle ( Vector2D  position,
double  radius,
Vector2D  velocity,
double  max_speed,
Vector2D  heading,
double  mass,
double  max_turn_rate,
double  max_force 
)

The constructor that should be used when creating a Vehicle without a name.

Parameters
positioninitial world position
radiusbounding radius
velocityinitial velocity
max_speedmaximum speed
headinginitial heading
massinitial mass
max_turn_ratehow fast the entity can turn (radians / second)
max_forcethe maximum force that can be applied by a steering behaviour

◆ Vehicle() [2/2]

game2dai.entities.Vehicle.Vehicle ( String  name,
Vector2D  position,
double  radius,
Vector2D  velocity,
double  max_speed,
Vector2D  heading,
double  mass,
double  max_turn_rate,
double  max_force 
)

The constructor that should be used when creating a Vehicle with a name.

Parameters
nameoptional name for the entity
positioninitial world position
radiusbounding radius
velocityinitial velocity
max_speedmaximum speed
headinginitial heading
massinitial mass
max_turn_ratehow fast the entity can turn (radians / second)
max_forcethe maximum force that can be applied by a steering behaviour

Member Function Documentation

◆ AP() [1/2]

AutoPilot game2dai.entities.Vehicle.AP ( )

Use this to access the auto-pilot object so that it can be modified.

◆ AP() [2/2]

Vehicle game2dai.entities.Vehicle.AP ( AutoPilot  ap)

Set the auto-pilot to use with this entity. Null vales and steering behaviour object with an owner are ignored.

Parameters
apan available steering behaviour

◆ forceRecorder()

ForceRecorder game2dai.entities.Vehicle.forceRecorder ( )

Get the force recorder if this vehicle has one. This is used by the World class when displaying all force logs

Returns
the force logger or null if it doesn't exist

◆ forceRecorderOff()

Vehicle game2dai.entities.Vehicle.forceRecorderOff ( )

Dump the force recorder on for this Vehicle. Any collected data will be lost.

◆ forceRecorderOn()

Vehicle game2dai.entities.Vehicle.forceRecorderOn ( )

Enable the force recorder on for this Vehicle. This will delete any collected data and start the logger.

The recorder will record the minimum, maximum average and number of readings for each steering force.

This is useful in tweaking max force values for vehicles and to help decide on the best force calculation method to use.

The force recorder should be switched off in the final sketch.

◆ hasForceRecorder()

boolean game2dai.entities.Vehicle.hasForceRecorder ( )

See if this vehicle has a force recorder.

Returns
true if force logger exists

◆ makeFromXML() [1/3]

static Vehicle[] game2dai.entities.Vehicle.makeFromXML ( File  xmlFile)
static

Alternative if not using Processing

Parameters
xmlFileFile to parse
Returns
an array of Buildings

◆ makeFromXML() [2/3]

static Vehicle[] game2dai.entities.Vehicle.makeFromXML ( PApplet  app,
String  xmlFilename 
)
static

This is the one to use with Processing

Parameters
app
xmlFilename
Returns
an array of Vehicles

◆ makeFromXML() [3/3]

static Vehicle[] game2dai.entities.Vehicle.makeFromXML ( String  xmlFilename)
static

Alternative if not using Processing

Parameters
xmlFilenamename of the file to parse
Returns
an array of Buildings

◆ maxForce()

double game2dai.entities.Vehicle.maxForce ( )

Get the maximum force that can be applied to this entity

Reimplemented from game2dai.entities.MovingEntity.

◆ printForceData()

void game2dai.entities.Vehicle.printForceData ( )

Display the steering force data for this Vehicle. If there is no recorder or no data has been collected for this Vehicle then nothing is displayed.

◆ toString()

String game2dai.entities.Vehicle.toString ( )

Entity ID number and name returned as a String

Reimplemented from game2dai.entities.BaseEntity.

◆ update()

void game2dai.entities.Vehicle.update ( double  deltaTime,
World  world 
)

Update method for any moving entity in the world that is under the influence of a steering behaviour.

Parameters
deltaTimeelapsed time since last update
worldthe game world object

Reimplemented from game2dai.entities.MovingEntity.

Member Data Documentation

◆ accel

Vector2D game2dai.entities.Vehicle.accel = new Vector2D()
protected

The acceleration created from the accumulated force

◆ ap

AutoPilot game2dai.entities.Vehicle.ap
private

The auto-pilot

◆ force

Vector2D game2dai.entities.Vehicle.force = new Vector2D()
protected

The accumulated force from the steering behaviours

◆ forceRecorder

ForceRecorder game2dai.entities.Vehicle.forceRecorder = null
protected

Used to record force calculation data for this vehicle.


The documentation for this class was generated from the following file: