|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object hermes.hshape.HShape
public abstract class HShape
An abstraction for a 2D shape, used for collision detection and response.
When the shape is linked to a being, shape's position should be a reference to the being's position.
In order for collision to work, all shapes must know how to collide with all other shapes.
Field Summary | |
---|---|
protected PVector |
_position
|
Constructor Summary | |
---|---|
protected |
HShape(PVector position)
Creates a new shape. |
Method Summary | |
---|---|
boolean |
collide(HShape other)
Detects a collision with another shape |
abstract boolean |
contains(float x,
float y)
|
abstract boolean |
contains(PVector point)
Whether the Shape contains the given point coordinates (boundary is inclusive). |
abstract void |
draw()
Shortcut method for drawing the shape on screen |
abstract HRectangle |
getBoundingBox()
Finds the smallest Rectangle that encloses the shape. |
PVector |
getPosition()
Returns the shape's position. |
abstract PVector |
projectionVector(HCircle other)
|
abstract PVector |
projectionVector(HPolygon other)
|
abstract PVector |
projectionVector(HRectangle other)
|
abstract PVector |
projectionVector(HShape other)
Finds the projection vector for a collision with another shape. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected PVector _position
Constructor Detail |
---|
protected HShape(PVector position)
position
- the shape's positionMethod Detail |
---|
public boolean collide(HShape other)
other
- the shape to collide with
public abstract PVector projectionVector(HShape other)
The projection vector is the vector by which one body could be displaced such that it no longer intersects the other body, by the shortest possible distance.
Each shape must contain methods for collision with all other types of HShapes. If you create your own type of shape, you will have to modify HShape (as well as its subclasses) to contain methods colliding it with the new type.
other
- the shape to collide with
public abstract PVector projectionVector(HRectangle other)
public abstract PVector projectionVector(HCircle other)
public abstract PVector projectionVector(HPolygon other)
public abstract boolean contains(PVector point)
point
- the point vector
public abstract boolean contains(float x, float y)
x
- the x coordinatey
- the y coordinate
public abstract HRectangle getBoundingBox()
public PVector getPosition()
public abstract void draw()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |