|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.rico.engine.game.AbstractBaseGame
public abstract class AbstractBaseGame
This abstract class represents a base class for writing a game. You will have to extend this class for your own project and implement the abstract methods like update(), draw() etc. This is the most basic version of an abstract game class available. It provides a camera only, but no inherent movement capabilities. You will have to implement your own movement capabilities by using the camera object together with InputActions and the InputManager class.
Constructor Summary | |
---|---|
AbstractBaseGame(java.lang.String title,
int maxFps)
Creates a new base game with the specified window title and upper framerate boundary. |
Method Summary | |
---|---|
void |
display(javax.media.opengl.GLAutoDrawable gld)
|
void |
displayChanged(javax.media.opengl.GLAutoDrawable drawable,
boolean modeChanged,
boolean deviceChanged)
|
abstract void |
draw(javax.media.opengl.GL gl)
This method is used to draw the scene and its content. |
void |
enableBackFaceCulling()
Enables back face culling for a (possibly) slight performance boost. |
javax.swing.JFrame |
getMainFrame()
Returns the main window (main frame) of the game |
javax.media.opengl.GLCanvas |
getOGLCanvas()
Returns the component that is the OpenGL canvas. |
void |
init(javax.media.opengl.GLAutoDrawable gld)
|
void |
initCamera(float camX,
float camY,
float camZ,
float rotX,
float rotY,
float near,
float far)
This method needs to be called before the start() method. |
abstract void |
initResources(javax.media.opengl.GLDrawable gld,
javax.media.opengl.GL gl,
int width,
int height)
This method is used to initialize all the objects and resources that are neccessary at startup of the game. |
boolean |
isSetDisplayFPS()
Determines whether or not the framerate is set to be displayed on screen. |
void |
resetElapsedTime()
Resets the calculation of the elapsed time between two frames. |
void |
reshape(javax.media.opengl.GLAutoDrawable gld,
int x,
int y,
int width,
int height)
|
void |
setDisplayFPS(boolean enable)
Sets whethter or not the framerate (frames per second) ought to be displayed. |
void |
setDisplayMode(EngineDisplayMode mode)
Sets the display mode of the game window. |
void |
start(GameIface game)
Call this method to start the game after every other method that influences the game startup has been called. |
void |
stop()
This method is used to savely stop the game. |
abstract void |
update(long elapsedTime)
This method is used to update the scene and its content. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractBaseGame(java.lang.String title, int maxFps)
title
- window titlemaxFps
- framerate to fix the game to, if possibleMethod Detail |
---|
public void init(javax.media.opengl.GLAutoDrawable gld)
init
in interface javax.media.opengl.GLEventListener
public void reshape(javax.media.opengl.GLAutoDrawable gld, int x, int y, int width, int height)
reshape
in interface javax.media.opengl.GLEventListener
public void display(javax.media.opengl.GLAutoDrawable gld)
display
in interface javax.media.opengl.GLEventListener
public void displayChanged(javax.media.opengl.GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
displayChanged
in interface javax.media.opengl.GLEventListener
public void start(GameIface game)
GameIface
start
in interface GameIface
game
- game objectpublic void stop()
GameIface
stop
in interface GameIface
public abstract void initResources(javax.media.opengl.GLDrawable gld, javax.media.opengl.GL gl, int width, int height)
GameIface
initResources
in interface GameIface
gld
- GLDrawable objectgl
- GL objectwidth
- window width (important viewport initialisation)height
- window height (important viewport initialisation)public abstract void update(long elapsedTime)
GameIface
update
in interface GameIface
elapsedTime
- time between two framespublic abstract void draw(javax.media.opengl.GL gl)
GameIface
draw
in interface GameIface
public void initCamera(float camX, float camY, float camZ, float rotX, float rotY, float near, float far)
GameIface
initCamera
in interface GameIface
camX
- camera's x coordinatecamY
- camera's y coordinatecamZ
- camera's z coordinaterotX
- camera's rotation around x axis (up/down)rotY
- camera's rotation around y axis (left/right)near
- near clipping plane distancefar
- far clipping plane distancepublic void resetElapsedTime()
GameIface
resetElapsedTime
in interface GameIface
public javax.swing.JFrame getMainFrame()
GameIface
getMainFrame
in interface GameIface
public javax.media.opengl.GLCanvas getOGLCanvas()
GameIface
getOGLCanvas
in interface GameIface
public void setDisplayMode(EngineDisplayMode mode)
GameIface
setDisplayMode
in interface GameIface
mode
- display modepublic void setDisplayFPS(boolean enable)
GameIface
setDisplayFPS
in interface GameIface
enable
- display fps --> true=yes, false=nopublic boolean isSetDisplayFPS()
GameIface
isSetDisplayFPS
in interface GameIface
public void enableBackFaceCulling()
GameIface
enableBackFaceCulling
in interface GameIface
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |