source.ucregents.playground.physics
Class MovingEntity

java.lang.Object
  extended by source.ucregents.playground.physics.BaseEntity
      extended by source.ucregents.playground.physics.MovingEntity
All Implemented Interfaces:
java.lang.Cloneable
Direct Known Subclasses:
Ball, Bot, Parallelogram, RangedForceEntity, Square, Triangle

public class MovingEntity
extends BaseEntity

This class extends base entity by added properties that allow the object to function in a 2d physics environment


Constructor Summary
MovingEntity()
          The default constructor uses no parameters and sets mass to one
MovingEntity(double x, double y, double dX, double dY)
          Constructs a moving entity with 30 width and 30 height, mass 1 and no friction
MovingEntity(double x, double y, double width, double height, double dX, double dY)
           
MovingEntity(double x, double y, double width, double height, float orientation, javax.vecmath.Vector2d initialVelocity, float inputMass)
          The main constructor for Moving entity, gives the entity the following properties
MovingEntity(java.awt.geom.Point2D.Double p, javax.vecmath.Vector2d v)
          Constructor that accepts position and velocity vectors
MovingEntity(PolygonOrCircle shape)
           
MovingEntity(PolygonOrCircle shape, float orientation, javax.vecmath.Vector2d initialVelocity, float inputMass)
          The main constructor for Moving entity, gives the entity the following properties
 
Method Summary
 void collide(BaseEntity obj2)
          Uses standard billard physics to change the velocities of the moving after the collision has occured.
 void collide(MovingEntity obj2)
          Uses standard billard physics to change the velocities of the entities after the collision has occured.
protected  java.lang.String DefaultImageLocation()
          Provides the location of the default image
 void Deserialize(CustomXMLReader reader)
           
 void Draw(java.awt.Graphics2D g2d, boolean verbose)
          Draws the entity
 double getAngularVelocity()
          Gets the angular Velocity
 javax.vecmath.Vector2d getCurrentTickVelocity()
          Returns the velocity as measured in current tick times, not seconds
 javax.vecmath.Vector2d getCurrentVelocity()
          Accessor for the current velocity of the entity
 double getMass()
          Accessor method for the entity's mass
 void increaseVelocity(javax.vecmath.Vector2d velocity)
          Increases the velocity by the given value
 void increaseXVelocity(double x)
          Increases the velocity in the x direction
 void increaseYVelocity(double y)
          Increases the velocity in the y direction
 boolean isStationary()
          Gets whether the entity is stationary or not
 boolean isUnstoppableForce()
          Tells whether the entity is user an Unstoppable Force.
 void moveCurrentVelocity()
          This moves the entity a fraction of its velocity according to the current tick period length.
 void moveVector(javax.vecmath.Vector2d toMove)
          Moves the entity a vector, there is no overlap checking with other entities
 void Serialize(CustomXMLWriter writer)
           
 void setAngularVelocity(double angularVel)
          Sets the angular velocity
 void setCurrentTickVelocity(javax.vecmath.Vector2d input)
          Sets the current velocity by being given a tick velocity
 void setCurrentVelocity(javax.vecmath.Vector2d velocity)
          Mutator for the current velocity of the entity
 void setMass(double newMass)
          Mutator for the entity's mass
 void setStationary(boolean stationary)
          Sets whether the entity is stationary or not
 void setUnstoppableForce(boolean uf)
          Sets if the entity is an Unstoppable Force
 
Methods inherited from class source.ucregents.playground.physics.BaseEntity
calculateAxes, clone, getActualFrameDimensions, getAxes, getAxesClone, getAxis, getBounciness, getCenterPoint, getDrawType, getEvents, getFrameColor, getFrictionConstant, getGradientColor, getImageOffset, getName, getOrientation, getResizingObject, getRoundedShapeMass, getScale, getShape, getShapeColor, getShapeFrame, getShapeMass, getSideVectors, getULPoint, getUserEvents, getVertexCount, getVerticesCoordinates, isCircle, isCollidable, isOverlapping, isPolygon, isSelected, isVisible, OnCenterScale, OnCollisionWith, OnLocationChange, OnOrientationChange, OnULScale, RegisterEvent, RegisterEvent, RegisterEvents, RemoveEvent, RemoveEvents, resetFrameColor, Scale, ScaleAroundCenter, setBounciness, setCenterPoint, setCenterPoint, setCollidable, setDrawType, setFrameColor, setFrictionConstant, setGradientColor, setImageOffset, setName, setOrientation, setScale, setSelected, setShapeColor, setULPoint, setULPoint, setVisible, toString, toXMLElement
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MovingEntity

public MovingEntity()
The default constructor uses no parameters and sets mass to one


MovingEntity

public MovingEntity(double x,
                    double y,
                    double dX,
                    double dY)
Constructs a moving entity with 30 width and 30 height, mass 1 and no friction

Parameters:
x - The x coordinate
y - The y coordinate
dX - The initial X velocity
dY - The initial Y velocity

MovingEntity

public MovingEntity(double x,
                    double y,
                    double width,
                    double height,
                    double dX,
                    double dY)

MovingEntity

public MovingEntity(double x,
                    double y,
                    double width,
                    double height,
                    float orientation,
                    javax.vecmath.Vector2d initialVelocity,
                    float inputMass)
The main constructor for Moving entity, gives the entity the following properties

Parameters:
x - The x coordinate
y - The y coordinate
width - The width of the entity
height - The height of the entity
orientation - The orientation of the entity
initialVelocity - The initial velocity of the entity
inputMass - The mass of the entity

MovingEntity

public MovingEntity(java.awt.geom.Point2D.Double p,
                    javax.vecmath.Vector2d v)
Constructor that accepts position and velocity vectors

Parameters:
p - The UL point of the entity
v - The velocity vector

MovingEntity

public MovingEntity(PolygonOrCircle shape)

MovingEntity

public MovingEntity(PolygonOrCircle shape,
                    float orientation,
                    javax.vecmath.Vector2d initialVelocity,
                    float inputMass)
The main constructor for Moving entity, gives the entity the following properties

Parameters:
shape - The Shape of the entity
orientation - The orientation of the entity
initialVelocity - The initial velocity of the entity
inputMass - The mass of the entity
Method Detail

collide

public void collide(BaseEntity obj2)
Uses standard billard physics to change the velocities of the moving after the collision has occured. The base entity will remain a base entity and not gain any momemtum.

Parameters:
obj2 - The base entity that the calling entity has collided with

collide

public void collide(MovingEntity obj2)
Uses standard billard physics to change the velocities of the entities after the collision has occured.

Parameters:
obj2 - The moving entity that the calling entity has collided with

DefaultImageLocation

protected java.lang.String DefaultImageLocation()
Description copied from class: BaseEntity
Provides the location of the default image

Overrides:
DefaultImageLocation in class BaseEntity
Returns:
Returns the location of the image

Deserialize

public void Deserialize(CustomXMLReader reader)
Overrides:
Deserialize in class BaseEntity

Draw

public void Draw(java.awt.Graphics2D g2d,
                 boolean verbose)
Draws the entity

Overrides:
Draw in class BaseEntity
Parameters:
g2d - The java.awt.Graphics2D object

getAngularVelocity

public double getAngularVelocity()
Gets the angular Velocity

Returns:
Theangular velocity

getCurrentTickVelocity

public javax.vecmath.Vector2d getCurrentTickVelocity()
Returns the velocity as measured in current tick times, not seconds

Returns:
The Velocity vector per tick

getCurrentVelocity

public javax.vecmath.Vector2d getCurrentVelocity()
Accessor for the current velocity of the entity

Returns:
The entity's current velocity

getMass

public double getMass()
Accessor method for the entity's mass

Returns:
The entity's mass

increaseVelocity

public void increaseVelocity(javax.vecmath.Vector2d velocity)
Increases the velocity by the given value

Parameters:
velocity - The vector to increase the velocity by

increaseXVelocity

public void increaseXVelocity(double x)
Increases the velocity in the x direction

Parameters:
x - The x component to increase by

increaseYVelocity

public void increaseYVelocity(double y)
Increases the velocity in the y direction

Parameters:
y - The y component to increase by

isStationary

public final boolean isStationary()
Gets whether the entity is stationary or not

Returns:
If it is stationary

isUnstoppableForce

public boolean isUnstoppableForce()
Tells whether the entity is user an Unstoppable Force. The entity will act like an "unstoppable force" and acts as a moving stationary object would

Returns:
If the entity is user controlled

moveCurrentVelocity

public void moveCurrentVelocity()
This moves the entity a fraction of its velocity according to the current tick period length.


moveVector

public void moveVector(javax.vecmath.Vector2d toMove)
Moves the entity a vector, there is no overlap checking with other entities

Parameters:
toMove - the vector to move the entity

Serialize

public void Serialize(CustomXMLWriter writer)
Overrides:
Serialize in class BaseEntity

setAngularVelocity

public void setAngularVelocity(double angularVel)
Sets the angular velocity

Parameters:
angularVel - the new angular velocity

setCurrentTickVelocity

public void setCurrentTickVelocity(javax.vecmath.Vector2d input)
Sets the current velocity by being given a tick velocity

Parameters:
input - The Velocity vector per tick

setCurrentVelocity

public void setCurrentVelocity(javax.vecmath.Vector2d velocity)
Mutator for the current velocity of the entity

Parameters:
velocity - The new velocity of the entity

setMass

public void setMass(double newMass)
Mutator for the entity's mass

Parameters:
newMass - The entities new mass value

setStationary

public final void setStationary(boolean stationary)
Sets whether the entity is stationary or not

Parameters:
stationary - If it is stationary

setUnstoppableForce

public void setUnstoppableForce(boolean uf)
Sets if the entity is an Unstoppable Force

Parameters:
uf - Sets if the entity is an Unstoppable Force