jme
Class AbstractGame

java.lang.Object
  extended byjme.AbstractGame

public abstract class AbstractGame
extends java.lang.Object

AbstractGame defines a common way to organize the flow of a game. A subclass must override the init, update, render and cleanup methods. A call to the start method causes the mainloop to begin. The main loop continues to run until finish is called.

Version:
0.1.0
Author:
Mark Powell

Constructor Summary
AbstractGame()
           
 
Method Summary
 void addSplashScreen(SplashScreen screen)
          addSplashScreen adds splash screens to be displayed during the showTitle portion of the initialization.
protected abstract  void cleanup()
          cleanup is called once after finish is called.
protected  void finish()
          finish is called to break out of the main game loop.
protected abstract  void initGame()
          initGame is called after showTitle to allow the creation of the game data.
protected abstract  void initSystem()
          initSystem is called once after start is called.
protected  void quit()
          quit is called to exit the program.
protected abstract  void reinit()
          reinit is called at any time by the client application to rebuild the sub systems.
protected abstract  void render()
          render is called each frame and is inteded to display the game information to the OpenGL context.
 void resetDisplay(int width, int height, int bpp, int freq, boolean fullscreen, java.lang.String title)
          resetDisplay resets the display system to reflect the new desired attributes.
 void showTitle()
          showTitle is called after initSystem and is intended to allow the display of any SplashScreens that the user desires.
 void start()
          start begins the game.
protected abstract  void update()
          update is called each frame and is intended to update the game state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractGame

public AbstractGame()
Method Detail

start

public final void start()
start begins the game. First, initSystem is called, next showTitle to display and splash screens and then initGame to set up the game data. After this it enters the main game loop. Here, each frame, update is called, then render. After the game loop is broken out of via a call to finish, cleanup is called. This method is final and cannot be overridden by the subclass.


showTitle

public final void showTitle()
showTitle is called after initSystem and is intended to allow the display of any SplashScreens that the user desires.


resetDisplay

public void resetDisplay(int width,
                         int height,
                         int bpp,
                         int freq,
                         boolean fullscreen,
                         java.lang.String title)
resetDisplay resets the display system to reflect the new desired attributes. It calls reinit to reset the Open GL rendering sub system. This falls on the shoulders of the subclass to implement.

Parameters:
width - new width of the resolution.
height - new height of the resolution.
bpp - the depth of the resolution.
freq - the frequency of the monitor.
fullscreen - fullscreen or not.
title - the name of the window.

addSplashScreen

public void addSplashScreen(SplashScreen screen)
addSplashScreen adds splash screens to be displayed during the showTitle portion of the initialization. All splash screens should be added in the initSystem phase.

Parameters:
screen - the splash screen to add.

quit

protected void quit()
quit is called to exit the program. By default it simply uses the System.exit() method.


finish

protected final void finish()
finish is called to break out of the main game loop. This method is final and cannot be overridden.


update

protected abstract void update()
update is called each frame and is intended to update the game state. That is run physics for game entities, check scores, etc.


render

protected abstract void render()
render is called each frame and is inteded to display the game information to the OpenGL context.


initSystem

protected abstract void initSystem()
initSystem is called once after start is called. This is meant to create all the necessary system components for the client application.


initGame

protected abstract void initGame()
initGame is called after showTitle to allow the creation of the game data.


reinit

protected abstract void reinit()
reinit is called at any time by the client application to rebuild the sub systems.


cleanup

protected abstract void cleanup()
cleanup is called once after finish is called. This is meant to clean up any created objects before exiting the application.