|
Breakout Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbreakout.WorldState
WorldState implements the World interface, providing an augmented container for BreakoutComponents. It also serves as a synchronization point for the program. In order for it to behave properly, it must be passed a JComponent GUI object before any components are added. It currently uses a dumb component intersection and rebound implementation.
World
Field Summary | |
Wall |
EAST
|
Wall |
NORTH
|
Wall |
SOUTH
|
Wall |
WEST
|
Fields inherited from interface breakout.World |
MAXX, MAXY, SHAPE_PRECISION |
Constructor Summary | |
WorldState(boolean networked)
Builds a WorldState object with only the components that make up the walls. |
Method Summary | |
void |
add(BreakoutComponent bc)
adds the component to the world and sends a WorldEvent if the component added was a brick. |
void |
addMouseAware(BreakoutComponent bc)
adds the component to the world using the add method and then registers the component with the GUI as a MouseListener and MouseMotionListener. |
void |
addWorldListener(WorldListener wl)
adds the given listener to the list of objects to be informed of changes in the world state |
void |
ballLeft(Ball b)
signal that the given ball has left the board for a better place (the other board). |
int |
getBallsLeft()
returns the number of balls left. |
BreakoutComponent |
intersects(BreakoutComponent bc)
Assumes the component checking for intersections is rectangular. |
java.util.Iterator |
iterator()
Returns an iterator that supports the remove operation. |
void |
killAll()
kills all components except the walls and empties the vector. |
boolean |
playing()
returns true if a game is in progress. |
void |
rebound(BreakoutComponent bc1,
BreakoutComponent bc2)
Assumes that two active components rebounding are equal mass and non active components have infinite mass. |
void |
removeAt(java.awt.Point loc)
removes the component at the given coordinates. |
void |
startPlaying()
indicate that game should start. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public final Wall NORTH
public final Wall SOUTH
public final Wall EAST
public final Wall WEST
Constructor Detail |
public WorldState(boolean networked)
networked
- specifies whether the worldstate will
be networked to another world.Wall
,
KillerWall
,
TransferWall
Method Detail |
public BreakoutComponent intersects(BreakoutComponent bc)
intersects
in interface World
bc
- component to test
World
public void rebound(BreakoutComponent bc1, BreakoutComponent bc2)
rebound
in interface World
bc1
- component to have reboundbc2
- component to have reboundpublic void add(BreakoutComponent bc)
add
in interface World
bc
- BreakoutComponent to addpublic void addMouseAware(BreakoutComponent bc)
addMouseAware
in interface World
bc
- BreakoutComponent to add to World and mouse listeners.
java.lang.ClassCastException
- if the BreakoutComponent does not
also implement MouseListener and MouseMotionListener.public java.util.Iterator iterator()
iterator
in interface World
public void removeAt(java.awt.Point loc)
World
removeAt
in interface World
loc
- coordinates of component to be removed.public void ballLeft(Ball b)
World
ballLeft
in interface World
b
- ball that has left. Ball is killed.public void killAll()
World
killAll
in interface World
public void startPlaying()
World
startPlaying
in interface World
public boolean playing()
World
playing
in interface World
public int getBallsLeft()
World
getBallsLeft
in interface World
public void addWorldListener(WorldListener wl)
World
addWorldListener
in interface World
wl
- WorldListener to add.
|
Breakout Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |