|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjme.AbstractGame
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.
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 |
public AbstractGame()
Method Detail |
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.
public final void showTitle()
showTitle
is called after initSystem
and is
intended to allow the display of any SplashScreens
that
the user desires.
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.
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.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.
screen
- the splash screen to add.protected void quit()
quit
is called to exit the program. By default it simply
uses the System.exit()
method.
protected final void finish()
finish
is called to break out of the main game loop. This
method is final and cannot be overridden.
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.
protected abstract void render()
render
is called each frame and is inteded to display
the game information to the OpenGL context.
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.
protected abstract void initGame()
initGame
is called after showTitle
to allow
the creation of the game data.
protected abstract void reinit()
reinit
is called at any time by the client application
to rebuild the sub systems.
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.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |