breakout
Interface World

All Known Implementing Classes:
WorldState

public interface World

public interface World encapsulates how BreakoutComponents and exterior entites interact with a game world.

Version:
$Id
Author:
benmv@olin.edu
See Also:
WorldListener, BreakoutComponent

Field Summary
static int MAXX
          maximum X value
static int MAXY
          maximum Y value
static float SHAPE_PRECISION
          This is the maximum distance between any two consecutive points in a shape describing a DefaultBreakoutComponent (in units of pixels)
 
Method Summary
 void add(BreakoutComponent bc)
          adds a component to the world
 void addMouseAware(BreakoutComponent bc)
          adds a component to the world and adds it to the MouseListeners and MouseMotionListeners
 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 bc)
          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)
          tests to see if anything else in the world intersects with the given component.
 Iterator iterator()
          returns an iterator over the elements of the World
 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)
          rebound causes the two entities to rebound off each other, mutating their DX and DY values.
 void removeAt(Point location)
          removes the component at the given coordinates.
 void startPlaying()
          indicate that game should start.
 

Field Detail

MAXX

public static final int MAXX
maximum X value

See Also:
Constant Field Values

MAXY

public static final int MAXY
maximum Y value

See Also:
Constant Field Values

SHAPE_PRECISION

public static final float SHAPE_PRECISION
This is the maximum distance between any two consecutive points in a shape describing a DefaultBreakoutComponent (in units of pixels)

See Also:
Constant Field Values
Method Detail

intersects

public BreakoutComponent intersects(BreakoutComponent bc)
tests to see if anything else in the world intersects with the given component. If more than one component intersects, an implementation dependant choice will be made a one returned.

Parameters:
bc - component to test
Returns:
BreakoutComponent or null if none.

rebound

public void rebound(BreakoutComponent bc1,
                    BreakoutComponent bc2)
rebound causes the two entities to rebound off each other, mutating their DX and DY values. if both objects are active, equal mass assumed. if only one object is active, the inactive one assumed to have infinite mass. if both are inactive, nothing happens.

Parameters:
bc1 - component to have rebound
bc2 - component to have rebound

add

public void add(BreakoutComponent bc)
adds a component to the world

Parameters:
bc - component to add.

addMouseAware

public void addMouseAware(BreakoutComponent bc)
adds a component to the world and adds it to the MouseListeners and MouseMotionListeners

Parameters:
bc - component to add
Throws:
ClassCastException - if argument doesn't implement the required interfaces.

iterator

public Iterator iterator()
returns an iterator over the elements of the World

Returns:
Iterator that supports remove();

removeAt

public void removeAt(Point location)
removes the component at the given coordinates. Coordinates must exactly match. Removes at most one component.

Parameters:
location - coordinates of component to be removed.

ballLeft

public void ballLeft(Ball bc)
signal that the given ball has left the board for a better place (the other board). The ball is kill()'ed.

Parameters:
bc - ball that has left. Ball is killed.

killAll

public void killAll()
kills all components except the walls and empties the vector. pauses for half a second to ensure all previous threads have died before continuing. Resets the number of balls.


startPlaying

public void startPlaying()
indicate that game should start. releases a ball from the store.


playing

public boolean playing()
returns true if a game is in progress.

Returns:
boolean true if a game is in progress.

getBallsLeft

public int getBallsLeft()
returns the number of balls left.

Returns:
int number of balls left

addWorldListener

public void addWorldListener(WorldListener wl)
adds the given listener to the list of objects to be informed of changes in the world state

Parameters:
wl - WorldListener to add.