|
Breakout Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object breakout.BasicBall
Basic implementation of a Ball, with velocity arbitrarily picked at magnitude 3 and direction pi/3.
Field Summary | |
static int |
DEFAULT_DIAM
The diameter of a BasicBall. |
protected boolean |
diedrebounding
Whether or not we died during the last resolveBounces phase of the tick. |
protected java.awt.geom.Point2D.Double |
location
The location of this BasicBall. |
protected java.awt.Dimension |
size
The size of this BasicBall. |
protected java.awt.geom.Line2D.Float |
velvect
The velocity vector of this BasicBall. |
Constructor Summary | |
BasicBall()
Creates a default ball with speed 3, direction pi/3, and diameter 10 |
Method Summary | |
boolean |
diedWhileRebounding()
Tells whether we hit the floor the last time we resolved bounces. |
java.awt.Point |
getLocation()
Gets the current coordinates of the ball, cast to an integer grid. |
java.awt.Shape |
getShape()
Gets the java.awt.Shape of this ball. |
java.awt.Dimension |
getSize()
Gets the current size of the ball. |
boolean |
hit(BreakoutComponent bc)
Called by an object implementing the Rebounding interface when it has detected an intersection with this ball. |
void |
paint(java.awt.Graphics g)
Paints the ball. |
void |
resolveBounces(java.util.Iterator it)
Checks all the BreakoutComponents in an iterator to see if it intersects them, hit()s them, and recalculates its velocity vector. |
void |
setLocation(java.awt.Point p)
Sets the location of this ball to (p.x, p.y). |
void |
update()
Called by World every tick; sets the new location of the ball, as affected by velocity. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_DIAM
protected java.awt.geom.Point2D.Double location
protected java.awt.Dimension size
protected java.awt.geom.Line2D.Float velvect
protected boolean diedrebounding
Constructor Detail |
public BasicBall()
Method Detail |
public void setLocation(java.awt.Point p)
setLocation
in interface BreakoutComponent
p
- A Point object representing the ball's intended location.public java.awt.Point getLocation()
getLocation
in interface BreakoutComponent
public java.awt.Dimension getSize()
getSize
in interface BreakoutComponent
public void update()
update
in interface BreakoutComponent
public boolean hit(BreakoutComponent bc)
hit
in interface BreakoutComponent
bc
- The BreakoutComponent/Rebounding object that detected the hit.
false
. Invalid to return true
, since Rebounding objects may not be
removed during the phase of the tick where hits are calculated.BreakoutComponent
,
Rebounding
public java.awt.Shape getShape()
getShape
in interface BreakoutComponent
public void paint(java.awt.Graphics g)
paint
in interface BreakoutComponent
g
- Graphics object for this ball's coordinate frame(ie, already located where we are).BoardPanel
public void resolveBounces(java.util.Iterator it)
resolveBounces
in interface Rebounding
it
- Iterator handed to it by World of all the BreakoutComponents on the current Board.public boolean diedWhileRebounding()
diedWhileRebounding
in interface Rebounding
true
if we died while rebounding; false
otherwise.
|
Breakout Problem Set Javadocs | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |