|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvooga.physicsEngine.geometry.GeometricParameters
vooga.physicsEngine.PhysicalParameters
vooga.physicsEngine.GamePhysicalParameters
public class GamePhysicalParameters
Class for linking PhysicalParameters
(basis of our independent
physics module) with PhysicalItem
(linkage with the game
engine). This links up the position and angular position of the two objects.
While this may seem bulky, it helps to decouple the core of the physics engine with the core of the game engine. One can view this setup as a type of controller between the game engine implementation of positions and rotations, which is intricately tied to their Texture objects (but may conceivably change in the future), with the physics engine implementation of positions and rotations. Hence, this class makes the rest of the physical engine closed (does not need to be changed) when game engine decides to change their underlying representation of rotations and positions, but also makes the physics engine open to adapting to whatever game engine decides to do. Only this adapter class needs to change when the game engine decides to change their core implementation. The apparent bulkiness of the design is a good sacrifice for the added independence.
Field Summary |
---|
Fields inherited from class vooga.physicsEngine.geometry.GeometricParameters |
---|
shape |
Constructor Summary | |
---|---|
GamePhysicalParameters(Shape shape,
PhysicalItem parent)
Create a GamePhysicalParameters object based on given
Shape and parent PhysicalItem. |
|
GamePhysicalParameters(Texture texture,
double centroidX,
double centroidY,
PhysicalItem parent)
Create a GamePhysicalParameters object using texture, location of where the centroid of the object is in the texture's coordinates, and the parent PhysicalItem |
Method Summary | |
---|---|
Vector2f |
getPosition()
|
boolean |
inCollisionWith(PhysicalItem otherObject)
Checks if the parent PhysicalItem is currently in collision with another PhysicalItem. |
void |
incrementAngularPosition(double difference)
|
void |
incrementPosition(Vector2f difference)
|
void |
positionChanged(PositionChangedEvent e)
This is called whenever a Tangible object updates its position. |
void |
rotationChanged(RotationChangedEvent e)
This is called whenever a Tangible object changes its rotation. |
void |
setAngularPosition(double angularPosition)
|
void |
setCentroidPosition(Vector2f position)
|
void |
setPosition(Vector2f position)
|
Methods inherited from class vooga.physicsEngine.geometry.GeometricParameters |
---|
drawShape, getAbsoluteCoordinate, getAngularPosition, getCentroidPosition, getJavaShape, getShape, getTransformedArea |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GamePhysicalParameters(Shape shape, PhysicalItem parent)
GamePhysicalParameters
object based on given
Shape
and parent PhysicalItem.
shape
- parent
- public GamePhysicalParameters(Texture texture, double centroidX, double centroidY, PhysicalItem parent)
texture
- centroidX
- centroidY
- parent
- Method Detail |
---|
public void setAngularPosition(double angularPosition)
setAngularPosition
in class GeometricParameters
angularPosition
- the angularPosition to setpublic void incrementAngularPosition(double difference)
incrementAngularPosition
in class GeometricParameters
public void setCentroidPosition(Vector2f position)
setCentroidPosition
in class GeometricParameters
position
- the centroid position to setpublic void incrementPosition(Vector2f difference)
incrementPosition
in class GeometricParameters
difference
- the change in positionpublic void setPosition(Vector2f position)
public void rotationChanged(RotationChangedEvent e)
RotationChangeListener
Tangible
object changes its rotation.
rotationChanged
in interface RotationChangeListener
e
- the RotationChangedEvent
public void positionChanged(PositionChangedEvent e)
PositionChangeListener
Tangible
object updates its position.
positionChanged
in interface PositionChangeListener
e
- the PositionChangedEvent
public Vector2f getPosition()
public boolean inCollisionWith(PhysicalItem otherObject)
otherObject
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |