Game Development Reference
In-Depth Information
The UpdateMenu() function updates each main menu item and also turns each of the items (which
are billboards) toward the camera by calling the UpdateObject3d() function. All the main menu items,
which are the new game button, the continue game button, the display high scores button, and the
copyright graphic, are processed here. (See Listing 9-8.)
Listing 9-8. Updating the Main Menu
void UpdateMenu(Camera Cam)
{
m_NewGameItem.UpdateObject3d(Cam);
m_ContinueGameItem.UpdateObject3d(Cam);
m_HighScoresItem.UpdateObject3d(Cam);
m_CopyRightItem.UpdateObject3d(Cam);
}
Creating the High Score Table
The high score table that holds the player's highest scores for the game consists of two classes: the
HighScoreEntry class and the HighScoreTable class.
The HighScoreEntry Class
The HighScoreEntry class holds the data for a high score entry. This class implements the Comparable
public interface and defines a function that allows the high score entries to be compared and sorted.
public class HighScoreEntry implements Comparable<HighScoreEntry>
The m_ItemValid variable is set to true, if this high score entry is valid, and should be displayed in the
high score table.
private boolean m_ItemValid;
The m_Initials variable holds the player's initials.
private String m_Initials;
The m_Score variable holds the player's score.
private int m_Score;
The HighScoreEntry constructor initializes the entry by setting the initials and score. (See Listing 9-9.)
Listing 9-9. HighScoreEntry Constructor
HighScoreEntry(String Initials,int Score)
{
m_Initials = Initials;
m_Score = Score;
}
 
Search WWH ::




Custom Search