Class MarbleGame

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--MarbleGame
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class MarbleGame
extends java.applet.Applet

MarbleGame is a 2-player version of the conventional game of shooting marbles. Based on the Pool class implemented by Steve Revilak. At the beginning of the game, player has to hit the Lag button to start the lagging session in order to determine who starts the shooting first. At this lagging session, two horizontal lines will be drawn each on the northern and southern parts of the ring. The players will shoot from the south to north direction attempting to get their shooters as close as possible to the northern horizontal line (but not over the line). The player with the shootest distance to the northern horizontal line starts the game first. The player that makes its shooter over the northern horizontal line will lose in this lagging session (means the other player will start the game first). If both players get their shooters over the northern horizontal line, they have to re-lag the game. During the game, each player's turn is signaled by the turn indicators on the lower left and right corner of the game window for player 1 and player 2, respectively. When it is the player's turn his/her turn indicator will glow red. The scores for both players are shown on the upper panel of the game window. The player will get his/her score based on the number of marbles he or she shoots out the ring (score of 1 for each marble). The game will be over if all the marbles have been shot out of the ring, and the winner is determined by the score received by each player. Note: if say, player 1's shooter hits player 2's shooter out of the ring, then player 1 will get the score obtained by player 2 up to that moment added to player 1's score and the game will be over with player 1 as the winner. The player will continue with his/her turn as long as he/she can keep shooting each marble out of the ring, even if his/her shooter goes outside the ring after the shot. The turn will go to the other player only if the current player cannot shoot the marble outside of the ring. To make a shot, the player should use the mouse to click on a point (a mark will be placed there) behind his/her shooter and another point behind the first point to determine the power and direction of the shot. The farther apart the two points are the greater the force that is applied to the shooter, thereby the faster and farther the shooter will travel. After clicking to make the two marks, the player needs to click on the shoot button to make the shot. The player's marble is indicated by a black dot on the center of the marble. Player 1 has the white marble and player 2 has the yellow marble. On the current version of this game, the shooter will be placed back in its original location outside the ring when it goes outside the ring. In the future version, the player will be able to choose where outside the ring to place his/her shooter.

Version:
1.0
Author:
Andi Sutedja
See Also:
Serialized Form

Inner Class Summary
protected  class MarbleGame.TableListener
          TableListener is a MouseEventListener that listens for clicks on the surface of the marble game canvas.
 
Inner classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Inner classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
static boolean isLag
          The flag to determine whether the game is currently in the Laggin session.
static int playerID
          The ID of the player currently in turn.
 
Fields inherited from class java.applet.Applet
accessibleContext
 
Fields inherited from class java.awt.Container
component, containerListener, layoutMgr, listeningBoundsChildren, listeningChildren, ncomponents
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowListenerK, x, y
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
MarbleGame()
          Construct this MarbleGame applet.
 
Method Summary
 void init()
          Initialize this MarbleGame applet.
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
, addNotify, constructComponentName
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, adjustListeningChildren, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventImpl, dispatchEventToSelf, doLayout, eventEnabled, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, nextFocus, numListening, paint, paintComponents, paintHeavyweightComponents, paramString, postProcessKeyEvent, postsOldMouseEvents, preferredSize, preProcessKeyEvent, print, printComponents, printHeavyweightComponents, processContainerEvent, processEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusOwner, setFont, setLayout, transferFocus, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resetGC, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

playerID

public static int playerID
The ID of the player currently in turn.

isLag

public static boolean isLag
The flag to determine whether the game is currently in the Laggin session.
Constructor Detail

MarbleGame

public MarbleGame()
Construct this MarbleGame applet. Mainly construct the game window layout.
Method Detail

init

public void init()
Initialize this MarbleGame applet.
Overrides:
init in class java.applet.Applet