public class MovingEntity extends BaseEntity
BaseEntity.DepthOrder
tag, tagNo
Constructor and Description |
---|
MovingEntity(java.lang.String name,
Vector2D position,
double radius,
Vector2D velocity,
double max_speed,
Vector2D heading,
double mass,
double max_turn_rate,
double max_force)
This is the constructor that should be used when creating a
named MovingEntity
|
MovingEntity(Vector2D position,
double radius,
Vector2D velocity,
double max_speed,
Vector2D heading,
double mass,
double max_turn_rate,
double max_force)
This is the constructor that should be used when creating an
unnamed MovingEntity
|
Modifier and Type | Method and Description |
---|---|
boolean |
canSee(World world,
double x0,
double y0)
This method determines whether this entity can see a particular location in the world.
|
boolean |
canSee(World world,
Vector2D pos)
This method determines whether this entity can see a particular location in the world.
|
void |
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. |
void |
draw(World world)
Deprecated.
|
Vector2D |
heading()
Get the current heading for this entity
|
MovingEntity |
heading(double x,
double y)
/**
Sets the direction the entity is facing.
|
MovingEntity |
heading(Vector2D h)
Sets the direction the entity is facing.
|
Vector2D |
headingAtRest()
get the default heading for this entity.
|
MovingEntity |
headingAtRest(Vector2D restHeading)
Set the default heading for this entity.
|
boolean |
isEitherSide(double x0,
double y0,
double x1,
double y1)
Determines whether two points are either side of this moving entity.
|
boolean |
isInDomain(Domain view)
Determine whether this moving entity is inside or part inside the domain.
|
boolean |
isOver(double px,
double py)
Determines whether a point is over this entity's collision circle
|
boolean |
isSpeedMaxedOut()
See if the current speed exceeds the maximum speed permitted.
|
double |
mass()
Get the mass of this entity.
|
void |
mass(double mass)
Change the mass of the entity.
|
double |
maxForce()
Gets the maximum force that can be applied to this entity.
|
MovingEntity |
maxForce(double mf)
Sets the maximum force that can be applied to this entity.
|
double |
maxSpeed()
Get the maximum speed allowed for this entity.
|
MovingEntity |
maxSpeed(double maxSpeed)
Sets the maximum speed this entity is allowed to reach
|
double |
maxTurnRate()
Get the maximum turn rate for this entity
|
MovingEntity |
maxTurnRate(double maxTurnRate)
Sets the maximum turnrate for this entity.
|
Vector2D |
prevPos()
Gets the position of the entity prior to the last update.
|
boolean |
rotateHeadingToAlignWith(double deltaTime,
Vector2D allignTo)
Rotate this entities heading to align with a vector over a given time period
|
boolean |
rotateHeadingToFacePosition(double deltaTime,
Vector2D faceTarget)
----------------------- RotateHeadingToFacePosition ------------------
given a target position, this method rotates the entity's heading and
side vectors by an amount not greater than m_dMaxTurnRate until it
directly faces the target.
|
Vector2D |
side()
Get the side vector for this entity.
|
double |
speed()
Get the entity's speed.
|
double |
speedSq()
Get the square of the entity's speed.
|
double |
turnRate()
Get the current turn rate
|
MovingEntity |
turnRate(double turnRate)
Set the current turnrate making sure it does not
exceed the maximum allowed.
|
void |
update(double deltaTime,
World world)
Update method for any moving entity in the world that is not under
the influence of a steering behaviour.
|
Vector2D |
velocity()
Gets the current velocity
|
MovingEntity |
velocity(double vx,
double vy)
Sets the current velocity
|
MovingEntity |
velocity(Vector2D newVel)
Sets the current velocity for this entity
|
double |
viewDistance()
Get the distance that this entity can see.
|
MovingEntity |
viewDistance(double viewDistance)
This sets the distance that this entity can see.
|
MovingEntity |
viewFactors(double viewDistance,
double viewFOV)
Sets the distance and total field of view angle for this entity.
|
double |
viewFOV()
Get the field of view for this entity.
|
MovingEntity |
viewFOV(double viewFOV)
Sets the total field of view angle for this entity.
|
Domain |
worldDomain()
Get the world domain for this entity.
|
MovingEntity |
worldDomain(Domain wd)
Set the world domain for this entity and its' constraint to the default value of SBF.WRAP
this means that when an entity leaves the domain it is wrapped to the other side.
|
MovingEntity |
worldDomain(Domain wd,
int constraint)
Set the world domain
|
int |
worldDomainConstraint()
Get the world domain constraint for this entity.
|
MovingEntity |
worldDomainConstraint(int constraint)
Set the constraint to be applied to the world domain.
|
addFSM, born, colRadius, colRadius, compareTo, die, FSM, hasFSM, ID, isEitherSide, isOverLapAllowed, isVisible, moveBy, moveBy, moveTo, moveTo, name, name, overLapAllowed, pos, removeFSM, renderer, renderer, toString, updateFSM, visible, Z, Z
public MovingEntity(Vector2D position, double radius, Vector2D velocity, double max_speed, Vector2D heading, double mass, double max_turn_rate, double max_force)
position
- initial world positionradius
- bounding radiusvelocity
- initial velocitymax_speed
- maximum speedheading
- initial headingmass
- initial massmax_turn_rate
- how fast the entity can turn (radians / second)max_force
- the maximum force that can be applied by a steering behaviourpublic MovingEntity(java.lang.String name, Vector2D position, double radius, Vector2D velocity, double max_speed, Vector2D heading, double mass, double max_turn_rate, double max_force)
name
- the name of the entityposition
- initial world positionradius
- bounding radiusvelocity
- initial velocitymax_speed
- maximum speedheading
- initial headingmass
- initial massmax_turn_rate
- how fast the entity can turn (radians / second)max_force
- the maximum force that can be applied by a steering behaviourpublic Vector2D prevPos()
public Vector2D velocity()
public MovingEntity velocity(Vector2D newVel)
newVel
- the new velocity vectorpublic MovingEntity velocity(double vx, double vy)
vx
- vy
- public MovingEntity heading(Vector2D h)
h
- public MovingEntity heading(double x, double y)
x
- y
- public Vector2D heading()
public Vector2D headingAtRest()
public MovingEntity headingAtRest(Vector2D restHeading)
nullthen the default heading is cancelled. The default heading will be normalised.
restHeading
- the headingAtRest to setpublic void mass(double mass)
mass
- the new masspublic double mass()
public Vector2D side()
public double maxSpeed()
public MovingEntity maxSpeed(double maxSpeed)
maxSpeed
- public double maxForce()
public MovingEntity maxForce(double mf)
mf
- max force allowedpublic boolean isSpeedMaxedOut()
public double speed()
public double speedSq()
public double maxTurnRate()
public MovingEntity maxTurnRate(double maxTurnRate)
maxTurnRate
- public double turnRate()
public MovingEntity turnRate(double turnRate)
turnRate
- public double viewDistance()
public MovingEntity viewDistance(double viewDistance)
viewDistance
- the viewDistance to setpublic double viewFOV()
public MovingEntity viewFOV(double viewFOV)
viewFOV
- the viewFOV to setpublic MovingEntity viewFactors(double viewDistance, double viewFOV)
viewDistance
- viewFOV
- the viewFOV to setpublic MovingEntity worldDomain(Domain wd)
wd
- the world domain for this entitypublic MovingEntity worldDomain(Domain wd, int constraint)
wd
- the world domain for this entityconstraint
- SBF.WRAP or SBF.REBOUND or SBF.PASS_THROUGHpublic MovingEntity worldDomainConstraint(int constraint)
constraint
- SBF.WRAP or SBF.REBOUND or SBF.PASS_THROUGHpublic Domain worldDomain()
public int worldDomainConstraint()
public boolean isEitherSide(double x0, double y0, double x1, double y1)
isEitherSide
in class BaseEntity
x0
- x position of first point of interesty0
- y position of first point of interestx1
- x position of second point of interesty1
- y position of second point of interestpublic boolean canSee(World world, double x0, double y0)
world
- the world responsible for this entityx0
- the x position of the location to testy0
- the y position of the location to testpublic boolean canSee(World world, Vector2D pos)
world
- the world responsible for this entitypos
- the location to testpublic boolean rotateHeadingToFacePosition(double deltaTime, Vector2D faceTarget)
deltaTime
- timefaceTarget
- the world position to facepublic boolean rotateHeadingToAlignWith(double deltaTime, Vector2D allignTo)
deltaTime
- time (seconds) to turn entityallignTo
- vector to align entities heading withpublic boolean isInDomain(Domain view)
isInDomain
in class BaseEntity
view
- the world domainpublic boolean isOver(double px, double py)
isOver
in class BaseEntity
px
- x position of point of interestpy
- y position of point of interestpublic void update(double deltaTime, World world)
update
in class BaseEntity
deltaTime
- elapsed time since last updateworld
- the game world objectpublic void draw(double elapsedTime, World world)
draw
in class BaseEntity
@Deprecated public void draw(World world)
BaseEntity
draw
in class BaseEntity
Processing library AI_for_2D_Games by Peter Lager. (C) 2013