|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectgame.pubsub.BasePublisher<PieceEvent>
game.Piece
public class Piece
The Piece class is used to represent various components in the game, including bricks, balls, the paddle and the boundaries of the game. It provides methods to move a piece and if this piece interacts with another. It also supports adjustment to its size and to its "life status".
| Field Summary | |
|---|---|
protected BoundingBox |
bb
|
| Constructor Summary | |
|---|---|
Piece(BoundingBox bb)
|
|
| Method Summary | |
|---|---|
boolean |
contains(lab4.Point p)
A subclass can override this method to produce more precise intersection calculation. |
void |
die()
Causes the piece to die. |
void |
dieSome(double factor)
Reduces the life status of the piece by a specified factor and informs all game components that are subscribers of this piece. |
BoundingBox |
getBB()
|
lab4.Point |
getCenter()
|
lab4.Vector |
getDirection()
|
int |
getHeight()
|
double |
getStatus()
|
int |
getWidth()
|
boolean |
intersects(Piece other)
The intersects method is used to determine when two pieces have come into contact with one another. |
boolean |
isDead()
|
java.lang.Iterable<lab4.Point> |
points()
Returns a list of points that are inside the piece. |
void |
setBB(BoundingBox bb)
Set the bounding box for the piece. |
void |
setCenter(lab4.Point p)
Changes the location of the point and informs subscribers of the change in location. |
void |
shrink(double factor)
Informs subscribers that the piece has shrunk. |
| Methods inherited from class game.pubsub.BasePublisher |
|---|
addSubscriber, notifySubscribers, removeSubscriber |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected BoundingBox bb
| Constructor Detail |
|---|
public Piece(BoundingBox bb)
| Method Detail |
|---|
public int getWidth()
public int getHeight()
public lab4.Point getCenter()
public BoundingBox getBB()
public void setBB(BoundingBox bb)
bb - is the new bounding boxpublic double getStatus()
public boolean isDead()
public lab4.Vector getDirection()
public boolean intersects(Piece other)
other - the second piece which is checked against this for intersection
public boolean contains(lab4.Point p)
p - is point to be tested for containment
public java.lang.Iterable<lab4.Point> points()
public void die()
public void dieSome(double factor)
factor - that is multiplied by the life status; ignored
if less than 0 or greater than 1public void setCenter(lab4.Point p)
p - new location for the center of the piecepublic void shrink(double factor)
factor - by which the size is changed
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||