com.golden.gamedev
Class Game

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Panel
                    |
                    +--java.applet.Applet
                          |
                          +--com.golden.gamedev.engine.graphics.HybridMode
                                |
                                +--com.golden.gamedev.Game
All Implemented Interfaces:
Accessible, BaseGraphics, ImageObserver, MenuContainer, Serializable

public abstract class Game
extends HybridMode

Golden T Game Engine (GTGE) Core Class, wrapping all available Game Engine.
Title: Game Engine
Description: Engine for creating Java Games
Copyright: Copyright (c) 2004
Company: Golden T Corporation

Version:
0.1
Author:
Paulus Tuerah
See Also:
Serialized Form

Field Summary
 BaseGraphics bsGraphics
           
 BaseInput bsInput
           
 BaseIO bsIO
           
 BaseLoader bsLoader
           
 BaseAudio bsMusic
           
 BaseAudio bsSound
           
 BaseTimer bsTimer
           
 GameFontManager fontManager
           
static String JAVA_VERSION
           
 
Fields inherited from class com.golden.gamedev.engine.graphics.HybridMode
APPLET_MODE, FULLSCREEN_MODE, gc, WINDOW_MODE
 
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
Game()
          Creates new instance of Game, please see note below.
 
Method Summary
 boolean checkPosMouse(int x1, int y1, int x2, int y2)
           
 boolean click()
           
protected  void createEnvironment(boolean fullscreen, boolean bufferstrategy)
           
 void finish()
           
 int getCurrentFPS()
           
 int getHeight()
           
 BufferedImage getImage(String imagefile)
           
 BufferedImage getImage(String imagefile, boolean useMask)
           
 BufferedImage[] getImages(String imagefile, int col, int row)
           
 BufferedImage[] getImages(String imagefile, int col, int row, boolean useMask)
           
 BufferedImage[] getImages(String imagefile, int col, int row, boolean useMask, int start, int end)
           
 BufferedImage[] getImages(String imagefile, int col, int row, boolean useMask, String sequence, int digit)
           
 BufferedImage[] getImages(String imagefile, int col, int row, int start, int end)
           
 BufferedImage[] getImages(String imagefile, int col, int row, String sequence, int digit)
           
 int getMouseX()
           
 int getMouseY()
           
 int getRandom(int low, int hi)
           
 int getRequestedFPS()
           
 int getWidth()
           
 void hideCursor()
           
protected  void initEngine()
          Game engine initialization.
abstract  void initResources()
           
 boolean keyDown(int keyCode)
           
 boolean keyPressed(int keyCode)
           
 void paint(Graphics g)
          Draw error messages, when user machine doesn't meet the minimum requirement.
 void playMusic(String audiofile)
          Begins playback of specified audiofile as background music.
 void playSound(String audiofile)
          Begins playback of specified audiofile as sound effect.
abstract  void render(Graphics2D g)
           
 boolean rightClick()
           
 void setFPS(int fps)
           
 void setMaskColor(Color c)
           
 void showCursor()
           
 void start()
           
 void stop()
           
 BufferedImage takeScreenShot()
           
 void takeScreenShot(File f)
           
abstract  void update()
           
 
Methods inherited from class com.golden.gamedev.engine.graphics.HybridMode
cleanup, flip, getBackBuffer, getComponent, getEnvironment, getEnvironmentString, getFrame, getSize, setup, setup
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, init, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, 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, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

JAVA_VERSION

public static final String JAVA_VERSION

bsGraphics

public final BaseGraphics bsGraphics

bsIO

public BaseIO bsIO

bsLoader

public BaseLoader bsLoader

bsInput

public BaseInput bsInput

bsTimer

public BaseTimer bsTimer

bsMusic

public BaseAudio bsMusic

bsSound

public BaseAudio bsSound

fontManager

public GameFontManager fontManager
Constructor Detail

Game

public Game()
Creates new instance of Game, please see note below.

Note: (instructions inherited from HybridMode)
Do not make any overloading constructors for this class.

All game variables must be initialized within initResources().

Game setup must be the first to setup after game creation,
setup(Dimension, fullscreen) and setup(Dimension, fullscreen, bufferstrategy).
(for Window and FullScreen mode only)

For example:

   public class TestGame extends Game {
       // writes only empty constructor,
       // or simply don't write any constructor
       public TestGame() { }

       // do not use both of these
   //  public TestGame(boolean fullscreen) {
   //      setup(new Dimension(640,480), fullscreen);
   //  }
   //  public TestGame() {
   //      setup(new Dimension(640,480), true);
   //  }

       public void initResources() {
           // put game initialization in here
       }

       public static void main(String[] args) {
           Game game = new TestGame();  // creates new game

           // sets fullscreen mode, with 640 x 480 display mode
           game.setup(new Dimension(640,480), true);

           game.start();  // starts the game
       }
   }
 

See Also:
initResources(), HybridMode.setup(Dimension, boolean), HybridMode.setup(Dimension, boolean, boolean)
Method Detail

createEnvironment

protected void createEnvironment(boolean fullscreen,
                                 boolean bufferstrategy)
Overrides:
createEnvironment in class HybridMode

initEngine

protected void initEngine()
Game engine initialization. Replacing one or more default game engine should be done within this method.

For example:

    protected void initEngine() {
       super.initEngine();

       bsTimer = new GageTimer();  // replace timer engine
    }
 


start

public void start()
Overrides:
start in class HybridMode

stop

public void stop()
Overrides:
stop in class Applet

finish

public void finish()

initResources

public abstract void initResources()

update

public abstract void update()

render

public abstract void render(Graphics2D g)

getRandom

public int getRandom(int low,
                     int hi)

getWidth

public int getWidth()
Overrides:
getWidth in class Component

getHeight

public int getHeight()
Overrides:
getHeight in class Component

takeScreenShot

public BufferedImage takeScreenShot()

takeScreenShot

public void takeScreenShot(File f)

playMusic

public void playMusic(String audiofile)
Begins playback of specified audiofile as background music. The default audio engine for music accepts only wave sound (*.wav) due to midi sound (*.mid) limitation, to replace this engine please do so in initEngine().
For example:
    protected void initEngine() {
       super.initEngine();

       // replace music audio engine
       bsMusic = new BaseAudio(bsIO, new MidiRenderer());
       bsMusic.setExclusive(true);   // only one can be played at a time
       bsMusic.setLoop(true);        // music looping
    }
 

See Also:
initEngine(), com.golden.gamedev.engine.audio

playSound

public void playSound(String audiofile)
Begins playback of specified audiofile as sound effect. The default sound audio engine accepts only wave sound (*.wav), to replace this engine please do so in initEngine().
For example:
    protected void initEngine() {
       super.initEngine();

       // replace sound audio engine
       bsSound = new BaseAudio(bsIO, new WaveRenderer());
    }
 

See Also:
initEngine(), com.golden.gamedev.engine.audio

setFPS

public void setFPS(int fps)

getCurrentFPS

public int getCurrentFPS()

getRequestedFPS

public int getRequestedFPS()

getMouseX

public int getMouseX()

getMouseY

public int getMouseY()

checkPosMouse

public boolean checkPosMouse(int x1,
                             int y1,
                             int x2,
                             int y2)

click

public boolean click()

rightClick

public boolean rightClick()

keyDown

public boolean keyDown(int keyCode)

keyPressed

public boolean keyPressed(int keyCode)

hideCursor

public void hideCursor()

showCursor

public void showCursor()

setMaskColor

public void setMaskColor(Color c)

getImage

public BufferedImage getImage(String imagefile,
                              boolean useMask)

getImage

public BufferedImage getImage(String imagefile)

getImages

public BufferedImage[] getImages(String imagefile,
                                 int col,
                                 int row,
                                 boolean useMask)

getImages

public BufferedImage[] getImages(String imagefile,
                                 int col,
                                 int row)

getImages

public BufferedImage[] getImages(String imagefile,
                                 int col,
                                 int row,
                                 boolean useMask,
                                 String sequence,
                                 int digit)

getImages

public BufferedImage[] getImages(String imagefile,
                                 int col,
                                 int row,
                                 String sequence,
                                 int digit)

getImages

public BufferedImage[] getImages(String imagefile,
                                 int col,
                                 int row,
                                 boolean useMask,
                                 int start,
                                 int end)

getImages

public BufferedImage[] getImages(String imagefile,
                                 int col,
                                 int row,
                                 int start,
                                 int end)

paint

public void paint(Graphics g)
Draw error messages, when user machine doesn't meet the minimum requirement.

Overrides:
paint in class Container