Game Development Reference
In-Depth Information
Listing 9-18. Sorting the High Score Table
void SortHighScoreTable()
{
Collections.sort(Arrays.asList(m_HighScoreTable));
// Only keep top 10 and make room for another to be added to end of array
m_HighScoreTable[MAX_SCORES-1].SetItemValidState(false);
}
The
ClearHighScoreTable()
function clears the high score table texture image held in
m_HighScoreTableImage
by copying the blank texture
m_BackGroundTexture
over it, using the
CopySubTextureToTexture()
function. (See Listing 9-19.)
Listing 9-19. Clearing the High Score Table
void ClearHighScoreTable()
{
Texture HighScoreTableTexture = m_HighScoreTableImage.GetTexture(0);
// Clear Composite Texture;
Bitmap BackGroundBitmap = m_BackGroundTexture.GetTextureBitMap();
HighScoreTableTexture.CopySubTextureToTexture(0, 0, 0, BackGroundBitmap);
}
The
RenderTitle()
function renders the text “High Scores” to
m_HighScoreTableImage
, which is the
billboard that holds the final composite texture for the high score table. (See Listing 9-20.)
Listing 9-20. Rendering the Title of the High Score Table
void RenderTitle()
{
m_Text.SetText("High".toCharArray());
m_Text.RenderToBillBoard(m_HighScoreTableImage, 0 , 0);
m_Text.SetText("Scores".toCharArray());
m_Text.RenderToBillBoard(m_HighScoreTableImage, 5*m_FontWidth , 0);
}
The
CopyHighScoreEntryToHighScoreTable()
function copies a high score entry to the final
composite
m_HighScoreTableImage
high score billboard that is used to display the final player's high
score. (See Listing 9-21.)
Listing 9-21. Copying the High Score Entry to the Final Composite Billboard Texture Object
void CopyHighScoreEntryToHighScoreTable(int Rank, Camera Cam, HighScoreEntry Item)
{
// Put HighScore Entry onto Final Composite Bitmap
// CharacterPosition
int HeightOffset = 10;
int CharPosX = 0;
int CharPosY = m_FontHeight + (Rank * (m_FontHeight + HeightOffset));