Game Development Reference
In-Depth Information
// Render Rank
String RankStr = Rank + ".";
m_Text.SetText(RankStr.toCharArray());
m_Text.RenderToBillBoard(m_HighScoreTableImage, CharPosX, CharPosY);
// Render Player Name/Initials and render to composite billboard
String Name = Item.GetInitials();
m_Text.SetText(Name.toCharArray());
CharPosX = CharPosX + m_FontWidth * 3;
m_Text.RenderToBillBoard(m_HighScoreTableImage, CharPosX, CharPosY);
// Render Numerical Value and render to composite billboard
String Score = String.valueOf(Item.GetScore());
m_Text.SetText(Score.toCharArray());
int BlankSpace = 4 * m_FontWidth;
CharPosX = CharPosX + Name.length() + BlankSpace;
m_Text.RenderToBillBoard(m_HighScoreTableImage, CharPosX, CharPosY);
}
The function does the following:
1.
Calculates the beginning x,y position for the high score entry, based on the
height of the character font to be used, the rank of the score (1st, 2nd, 3rd, etc.),
and the
HeightOffset
variable
2.
Renders the high score entry's rank to the
m_HighScoreTableImage
billboard
3.
Renders the high score entry's player's initials to the
m_HighScoreTableImage
billboard
4.
Renders the high score entry's player's score to the
m_HighScoreTableImage
billboard
The
UpdateHighScoreTable()
function updates the high score table. (See Listing 9-22.)
Listing 9-22. Updating the High Score Table
void UpdateHighScoreTable(Camera Cam)
{
if (m_Dirty)
{
// Sort High Score Table in descending order for score
SortHighScoreTable();
// Clear High Score Table and set background texture
ClearHighScoreTable();
// Render Title
RenderTitle();