Rev 213 |
Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
package com.gebauz.Bauzoid.app;
import com.gebauz.Bauzoid.gamestates.GameStateManager;
import com.gebauz.Bauzoid.graphics.Graphics;
/** Root object for the game. Manages game-global objects, acts as the root of the game graph, and kicks off update and render calls.
*
* This is the parent class for the following subsystems:
* - GameStateManager: Root object for game states.
* - Graphics: Root object for all graphics objects
* - Audio: Root object for all audio objects
* - ..
*
* It also offers convenient access to the Android application's Context
*/
public class Game
{
private GameStateManager mGameStateManager =
null;
private Graphics mGraphics =
null;
// private Audio mAudio = null;
/** Constructor. */
public Game
()
{
// Set the context to use for engine exceptions
mGameStateManager =
new GameStateManager
(this);
mGraphics =
new Graphics(this);
// mAudio = new Audio(this);
}
/** Called for game-global initialization. */
public void init
()
{
mGraphics.
init();
mGameStateManager.
init();
}
/** Called for game-global destruction. */
public void exit
()
{
mGameStateManager.
exit();
mGraphics.
exit();
}
/** Update game logic state. */
public void update
(float deltaTime
)
{
mGameStateManager.
update(deltaTime
);
// mAudio.update(deltaTime);
}
/** Render game. */
public void render
()
{
mGameStateManager.
render();
// mAudio.render();
}
/** Called when the surface dimensions have changed. */
public void resize
(int w,
int h
)
{
mGraphics.
updateSurfaceDimensions(w, h
);
mGameStateManager.
onSurfaceChanged(w, h
);
}
/** Called when the OpenGL Context is about to be destroyed. */
public void pause
()
{
mGraphics.
onSurfaceLost();
}
/** Called when the OpenGL Context has been recreated after onSurfaceLost(). */
public void resume
()
{
mGraphics.
onSurfaceRecreated();
}
/** Get the main graphics object. */
public final Graphics getGraphics
()
{
return mGraphics
;
}
/** Get the main audio object. */
/* public final Audio getAudio()
{
return mAudio;
}*/
/** Get the GameStateManager. */
public final GameStateManager getGameStateManager
()
{
return mGameStateManager
;
}
}