|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.awt.Component
|
+--nu.dll.pong.PongPanel
The component that is the game. Creates at least two threads: one for ball animation (class BallMoverThread), which takes care of ball movement, collisions and some other animation details. The other is the ScoreAnimatorThread class, which sole purpose is to nicely increment the displayed score on screen. These threads (and the game) are started upon invokation of the start() method.
Main-class for running the game stand-alone, Serialized Form| Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
| Fields inherited from class java.awt.Component |
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
PongPanel()
Creates a Pong component using the default values and components. |
|
PongPanel(int startLevel,
boolean _autoPilot,
boolean embedded,
Sound _sound,
LevelLoader levelLoader,
ImageLoader _imageLoader)
Creates a custom Pong component. |
|
| Method Summary | |
void |
brickDead(int x,
int y)
Called when a brick is zapped. |
void |
brickHit(int x,
int y)
Called when a brick is hit but not zapped. |
void |
changeLevel(int levelNo)
Changes the current level to the given level number and resets game state. |
static void |
criticalError(java.lang.String message)
Displays an error dialog, then exits. |
static void |
criticalErrorDialog(java.lang.String message)
An error dialog for critical error messages. |
static void |
errorDialog(java.lang.String title,
java.lang.String message)
Displays a modal error dialog. |
void |
flashBrick(int x,
int y,
long time)
Flashes a brick for time milliseconds. |
void |
gameOver()
Called when all balls have been lost. |
long |
gameOverFor()
Returns the time (in milliseconds) since the game ended. |
static void |
handleException(java.lang.String title,
java.lang.String message,
java.lang.Throwable e)
Display information and stack trace for the given exception, then exits. |
static void |
handleException(java.lang.String title,
java.lang.String message,
java.lang.Throwable e,
boolean die)
Display information and stack trace for the given exception. |
boolean |
imageUpdate(java.awt.Image img,
int infoflags,
int x,
int y,
int width,
int height)
Obsolete (FileImageLoader takes care of this now). |
protected void |
init(int startLevel,
boolean _autoPilot,
boolean embedded,
Sound _sound,
LevelLoader levelLoader,
ImageLoader _imageLoader)
Initializes the game state. |
protected void |
initImages(ImageLoader _imageLoader)
|
protected void |
initLevels(LevelLoader levelLoader)
|
protected void |
initSounds(Sound _sound)
|
protected void |
initThreads()
|
boolean |
isGameOver()
Returns true if the game has ended because all balls have been lost. |
void |
keyPressed(java.awt.event.KeyEvent e)
|
void |
keyReleased(java.awt.event.KeyEvent e)
|
void |
keyTyped(java.awt.event.KeyEvent e)
|
void |
levelComplete()
Called when all bricks have been cleared. |
void |
lostBall()
Called when the ball is lost. |
static void |
modalDialog(int icon,
java.lang.String title,
java.lang.String message)
Displays a modal dialog (JOptionPane) with the given attributes. |
void |
mouseClicked(java.awt.event.MouseEvent e)
|
void |
mouseDragged(java.awt.event.MouseEvent e)
|
void |
mouseEntered(java.awt.event.MouseEvent e)
|
void |
mouseExited(java.awt.event.MouseEvent e)
|
void |
mouseMoved(java.awt.event.MouseEvent e)
|
void |
mousePressed(java.awt.event.MouseEvent e)
|
void |
mouseReleased(java.awt.event.MouseEvent e)
|
void |
moveBall(int x,
int y)
Moves the ball to the given coordinates. |
static java.lang.String |
pad(int l,
char padding,
java.lang.String s)
Returns a new String padded to the given length by inserting the necessary number of the specified character at the beginning. |
void |
paint(java.awt.Graphics g)
|
void |
paintBonusBalls(java.awt.Graphics g)
Paints the Bonus Balls (if any on screen). |
void |
paintBricks(java.awt.Graphics g)
Paint the active bricks. |
void |
paintCredits(java.awt.Graphics g)
Paints the credits stuff. |
void |
paintText(java.awt.Graphics g)
Paints the status text. |
void |
repaintCredits(double x,
boolean showCredits)
Hint that the credits row needs refreshing. |
void |
repaintStatus()
Hints that the status row needs refreshing. |
void |
resetGame()
Resets the game state. |
void |
resetPaddle()
Resets the paddle state. |
void |
setAutoPilot(boolean b)
Enabled or disables the silly auto pilot. |
protected void |
setCursor(int type)
|
void |
setupBricks(Level l)
Sets up the GUI and state tables according the given Level. |
static void |
showHelp()
Displays the in-game help. |
void |
start()
Starts the game. |
protected void |
toggleCursor()
|
void |
update(java.awt.Graphics g)
|
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, validate |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public PongPanel()
throws java.io.IOException
public PongPanel(int startLevel,
boolean _autoPilot,
boolean embedded,
Sound _sound,
LevelLoader levelLoader,
ImageLoader _imageLoader)
throws java.io.IOException
| Method Detail |
protected void initLevels(LevelLoader levelLoader)
protected void initImages(ImageLoader _imageLoader)
throws java.io.IOException
protected void initSounds(Sound _sound)
throws java.io.IOException
protected void initThreads()
protected void toggleCursor()
protected void setCursor(int type)
protected void init(int startLevel,
boolean _autoPilot,
boolean embedded,
Sound _sound,
LevelLoader levelLoader,
ImageLoader _imageLoader)
throws java.io.IOException
public void start()
public void mouseMoved(java.awt.event.MouseEvent e)
mouseMoved in interface java.awt.event.MouseMotionListenerpublic void mouseDragged(java.awt.event.MouseEvent e)
mouseDragged in interface java.awt.event.MouseMotionListenerpublic void mouseClicked(java.awt.event.MouseEvent e)
mouseClicked in interface java.awt.event.MouseListenerpublic void mouseEntered(java.awt.event.MouseEvent e)
mouseEntered in interface java.awt.event.MouseListenerpublic void mouseExited(java.awt.event.MouseEvent e)
mouseExited in interface java.awt.event.MouseListenerpublic void mousePressed(java.awt.event.MouseEvent e)
mousePressed in interface java.awt.event.MouseListenerpublic void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased in interface java.awt.event.MouseListenerpublic void keyTyped(java.awt.event.KeyEvent e)
keyTyped in interface java.awt.event.KeyListenerpublic void keyPressed(java.awt.event.KeyEvent e)
keyPressed in interface java.awt.event.KeyListenerpublic void keyReleased(java.awt.event.KeyEvent e)
keyReleased in interface java.awt.event.KeyListenerpublic void setAutoPilot(boolean b)
public void setupBricks(Level l)
public static java.lang.String pad(int l,
char padding,
java.lang.String s)
public void resetGame()
public void resetPaddle()
public void lostBall()
public void gameOver()
public boolean isGameOver()
true if the game has ended because all balls have been lost.public long gameOverFor()
public void brickDead(int x,
int y)
public void brickHit(int x,
int y)
public void changeLevel(int levelNo)
public void levelComplete()
public void moveBall(int x,
int y)
public void paintBricks(java.awt.Graphics g)
public void flashBrick(int x,
int y,
long time)
time milliseconds.public void paintCredits(java.awt.Graphics g)
public void paintText(java.awt.Graphics g)
public void paintBonusBalls(java.awt.Graphics g)
public void update(java.awt.Graphics g)
update in class java.awt.Componentpublic void paint(java.awt.Graphics g)
paint in class java.awt.Componentpublic void repaintStatus()
public void repaintCredits(double x,
boolean showCredits)
public boolean imageUpdate(java.awt.Image img,
int infoflags,
int x,
int y,
int width,
int height)
imageUpdate in interface java.awt.image.ImageObserverimageUpdate in class java.awt.Componentpublic static void showHelp()
public static void modalDialog(int icon,
java.lang.String title,
java.lang.String message)
public static void errorDialog(java.lang.String title,
java.lang.String message)
public static void criticalErrorDialog(java.lang.String message)
public static void criticalError(java.lang.String message)
public static void handleException(java.lang.String title,
java.lang.String message,
java.lang.Throwable e)
public static void handleException(java.lang.String title,
java.lang.String message,
java.lang.Throwable e,
boolean die)
die is true, the application will exit when the user clicks 'OK'.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||