breakout
Class SimpleBall
java.lang.Object
breakout.DefaultActiveBreakoutComponent
breakout.SimpleBall
- All Implemented Interfaces:
- ActiveBreakoutComponent, Ball, BreakoutComponent, java.lang.Runnable
- public class SimpleBall
- extends DefaultActiveBreakoutComponent
- implements Ball
SimpleBall is an active component that bounces around hitting
things.
- Version:
- $Id: SimpleBall.java,v 1.2 2004/03/26 20:39:33 gus Exp $
- Author:
- benmv@olin.edu
- See Also:
ActiveBreakoutComponent
Constructor Summary |
SimpleBall(java.awt.Point location,
java.awt.Dimension size,
World w,
double theta,
int timeBetweenActs,
java.awt.Color c)
|
SimpleBall(java.awt.Point location,
java.awt.Dimension size,
World w,
java.awt.Point direction,
int timeBetweenActs,
java.awt.Color c)
|
Method Summary |
void |
act()
actively interact with the world. |
java.awt.Shape |
getShape()
returns the actual shape of the object. |
void |
hitBy(BreakoutComponent striker)
the component has been struck by the given component |
void |
paint(java.awt.Graphics g)
renders this component to the screen. |
Methods inherited from class breakout.DefaultActiveBreakoutComponent |
getCenter, getDirection, getLocation, getSize, getTimeBetweenActs, isDead, isTransient, kill, run, setDirection, setLocation, setWorld |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SimpleBall
public SimpleBall(java.awt.Point location,
java.awt.Dimension size,
World w,
java.awt.Point direction,
int timeBetweenActs,
java.awt.Color c)
SimpleBall
public SimpleBall(java.awt.Point location,
java.awt.Dimension size,
World w,
double theta,
int timeBetweenActs,
java.awt.Color c)
getShape
public java.awt.Shape getShape()
- Description copied from interface:
BreakoutComponent
- returns the actual shape of the object. Used for intersection
and rebound. Shape should be in world coordinates, not local
coordinates (i.e. not relative to upper left corner of component)
- Specified by:
getShape
in interface BreakoutComponent
- Overrides:
getShape
in class DefaultActiveBreakoutComponent
- Returns:
- Shape Rectangle according to components location and
size.
paint
public void paint(java.awt.Graphics g)
- Description copied from interface:
BreakoutComponent
- renders this component to the screen. Origin of graphics
has been translated to upper-left corner of component.
- Specified by:
paint
in interface BreakoutComponent
- Specified by:
paint
in class DefaultActiveBreakoutComponent
- Parameters:
g
- Graphics object used to draw with.
hitBy
public void hitBy(BreakoutComponent striker)
- Description copied from interface:
BreakoutComponent
- the component has been struck by the given component
- Specified by:
hitBy
in interface BreakoutComponent
- Specified by:
hitBy
in class DefaultActiveBreakoutComponent
- Parameters:
striker
- BreakoutComponent that struck this component
act
public void act()
- Description copied from interface:
ActiveBreakoutComponent
- actively interact with the world. Before act() is called the
component is moved forward according to it's direction.
- Specified by:
act
in interface ActiveBreakoutComponent
- Specified by:
act
in class DefaultActiveBreakoutComponent