Game Development Reference
In-Depth Information
// Load in Player's Health
int Health = settings.getInt("Health", 100);
m_Pyramid.GetObjectStats().SetHealth(Health);
// Can Continue
m_CanContinue = settings.getBoolean("CanContinue", false);
// Camera
m_Camera.LoadCameraState("Camera");
// Arena Objects Set
m_ArenaObjectsSet.LoadSet(ARENA_OBJECTS_HANDLE);
// Tank Fleet
m_TankFleet.LoadSet(TANK_FLEET_HANDLE);
}
Adding in the Game Over Game State
One of the final features we must add to the final game is a game over message. We will have to
modify the MyGLRenderer class to add new code to handle the game over graphics and game logic.
The
m_GameOverBillBoard
variable holds the graphic that tells the player that the game is over.
private BillBoard m_GameOverBillBoard;
The
m_GameOverPauseTime
variable holds the minimum time for displaying the game over graphic
before user input is to be processed for continuing the game.
private long m_GameOverPauseTime = 1000;
The
m_GameOverStartTime
variable holds the time the game ended.
private long m_GameOverStartTime;
The
CreateGameOverBillBoard()
function creates the game over billboard that contains the game
over graphic that is displayed when the player's game ends. The billboard is actually created by
calling the function
CreateInitBillBoard()
. (See Listing 10-36.)
Listing 10-36. Creating the Game Over BillBoard
void CreateGameOverBillBoard(Context iContext)
{
// Put Game over Billboard in front of camera
int TextureResourceID = R.drawable.gameover;
Vector3 Position= new Vector3(0,0,0);
Vector3 Scale = new Vector3(1 , 0.5f, 0.5f);
m_GameOverBillBoard = CreateInitBillBoard(iContext,TextureResourceID, Position, Scale);
}