com.planeth.gtroids.environment
Class GamePanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bycom.planeth.gtroids.environment.GenericGamePanel
                      extended bycom.planeth.gtroids.environment.GamePanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, IThreadControllable, ITimeControllable, java.awt.MenuContainer, java.io.Serializable

public class GamePanel
extends GenericGamePanel
implements IThreadControllable, ITimeControllable

The GamePanel contains the physical gameEnvironment and handles the main game tasks.
It defines furthermore the Interface between GameObjects and Graphics.

Author:
Andreas Grässer, gal@planet-h.com.
created May 7, 2005
See Also:
ITimeControllable, TimedObjectThread, GameStats, Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
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
GamePanel()
          Constructor for GamePanel.
GamePanel(double gravit)
          Constructor for GamePanel.
 
Method Summary
 void activateBomb()
          Activates a smartBomb
 void addPhysicalObject(AbstractPhysicalObject physicalObject)
          Adds a AbstractPhysicalObject to the GampePanel
 void cleanUp()
          Cleans up the game environment (free all resources)
 void countEnemyKilled()
          Counter for killed enemies.
 void createBoss()
          Creates a Boss enemy (if not already one is existing)
 void decreaseSpeed(int nrOfSteps)
          Decreases the gameSpeed with the passed number of predefined speed steps.
 void doNextStep()
          Does one game step (update, render, paint)
 void enableBlackHoles()
          Enables the BlackHoles
Creates 2 BlackHole Objects.
 void enableMaxGravit()
          Enables the max gravitation (Asteroid trap)
Changes the normal gravitation to something like earth gravit.
 Boss getBoss()
          Returns the Boss enemy, if one is existing
 WordReader getCheatReader()
          Returns the cheatReader
 FieldedArea getFieldedArea()
          Returns the fieldedArea (Object container)
 double getGravit()
          Returns the gravit.
 int getNonPlayerShipCount()
          Returns the complete number of nonPlayerShips used in the game
 Ship getShip()
          Returns the PlayerShip, if one is existing
 double getSpeed()
          Returns the gameSpeed.
 GameStats getStats()
          Returns the gameStats
 void increaseSpeed()
          Increases the gameSpeed with one predefined speed step
 void initGameField()
          Initializes the gamefield
 boolean isEarthGravitActive()
          Returns true, if any earth like gravitation is active.
 boolean isPaused()
          Returns true, if the game is paused
 boolean isReadyToDie()
          Returns true, if the GamePanel is ready to get terminated
 void notifyBossKill()
          Notifies the GamePanel that a Boss Enemy has been killed
Initiate the level change.
 void pause(boolean pauseState)
          Pauses/unpauses the game
 void setReadyToDie()
          Sets the GamePanel readyToDie
 void setResourceLoader(java.lang.Thread resourceLoader)
          Sets the resourceLoader.
 void setResourceProgressBar(javax.swing.JProgressBar resourceProgressBar)
          Sets the resourceProgressBar.
 void setSpeed(double speed)
          Sets the gameSpeed.
 void startNewGame()
          Starts a new game
 
Methods inherited from class com.planeth.gtroids.environment.GenericGamePanel
countFrames, getCenter, getEastBrd, getFramesPerSecond, getNorthBrd, getSouthBrd, getWestBrd, isAllowMoreGeometry
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GamePanel

public GamePanel()
Constructor for GamePanel.


GamePanel

public GamePanel(double gravit)
Constructor for GamePanel.

Parameters:
gravit - base gravitation value for the GamePanel
Method Detail

startNewGame

public void startNewGame()
Starts a new game


pause

public void pause(boolean pauseState)
Pauses/unpauses the game

Specified by:
pause in interface ITimeControllable
Parameters:
pauseState -
See Also:
ITimeControllable.pause(boolean)

isPaused

public boolean isPaused()
Returns true, if the game is paused

Returns:
Returns true, if the game is paused

initGameField

public void initGameField()
Initializes the gamefield


cleanUp

public void cleanUp()
Cleans up the game environment (free all resources)


addPhysicalObject

public void addPhysicalObject(AbstractPhysicalObject physicalObject)
Adds a AbstractPhysicalObject to the GampePanel

Parameters:
physicalObject - the Object to be added

doNextStep

public void doNextStep()
Does one game step (update, render, paint)

Specified by:
doNextStep in interface IThreadControllable
See Also:
IThreadControllable.doNextStep()

getNonPlayerShipCount

public int getNonPlayerShipCount()
Returns the complete number of nonPlayerShips used in the game

Returns:
Returns the complete number of nonPlayerShips used in the game

getShip

public Ship getShip()
Returns the PlayerShip, if one is existing

Returns:
Returns the PlayerShip, if one is existing

isReadyToDie

public boolean isReadyToDie()
Returns true, if the GamePanel is ready to get terminated

Specified by:
isReadyToDie in interface IThreadControllable
Returns:
Returns true, if the IThreadControllable is ready to die
See Also:
IThreadControllable.isReadyToDie()

setReadyToDie

public void setReadyToDie()
Sets the GamePanel readyToDie

Specified by:
setReadyToDie in interface IThreadControllable

activateBomb

public void activateBomb()
Activates a smartBomb


enableBlackHoles

public void enableBlackHoles()
Enables the BlackHoles
Creates 2 BlackHole Objects.


createBoss

public void createBoss()
Creates a Boss enemy (if not already one is existing)


notifyBossKill

public void notifyBossKill()
Notifies the GamePanel that a Boss Enemy has been killed
Initiate the level change.


getBoss

public Boss getBoss()
Returns the Boss enemy, if one is existing

Returns:
Returns the Boss enemy, if one is existing

countEnemyKilled

public void countEnemyKilled()
Counter for killed enemies.
This method is called each time an enemy is killed.
It is used to know when a Boss has to be created.


enableMaxGravit

public void enableMaxGravit()
Enables the max gravitation (Asteroid trap)
Changes the normal gravitation to something like earth gravit.


getGravit

public double getGravit()
Returns the gravit.

Returns:
Returns the gravit.

isEarthGravitActive

public boolean isEarthGravitActive()
Returns true, if any earth like gravitation is active.

Returns:
Returns true, if any earth like gravitation is active.

getSpeed

public double getSpeed()
Returns the gameSpeed.

Returns:
Returns the gameSpeed.

setSpeed

public void setSpeed(double speed)
Sets the gameSpeed.

Parameters:
speed - The speed to set

increaseSpeed

public void increaseSpeed()
Increases the gameSpeed with one predefined speed step


decreaseSpeed

public void decreaseSpeed(int nrOfSteps)
Decreases the gameSpeed with the passed number of predefined speed steps.

Parameters:
nrOfSteps - number of speed steps to decrease

getStats

public GameStats getStats()
Returns the gameStats

Returns:
Returns the gameStats

getFieldedArea

public FieldedArea getFieldedArea()
Returns the fieldedArea (Object container)

Returns:
Returns the fieldedArea (Object container)

getCheatReader

public WordReader getCheatReader()
Returns the cheatReader

Returns:
Returns the cheatReader.

setResourceLoader

public void setResourceLoader(java.lang.Thread resourceLoader)
Sets the resourceLoader.
The ResourceLoader contains information about the loading state of required resources (audioFiles, etc.)

Parameters:
resourceLoader - The resourceLoader to set.

setResourceProgressBar

public void setResourceProgressBar(javax.swing.JProgressBar resourceProgressBar)
Sets the resourceProgressBar.
The resourceProgressBar displays the loading state of required resources (audioFiles, etc.)

Parameters:
resourceProgressBar - The resourceProgressBar to set.