Interface components
While we currently use an undocumented set of keyboard keys to rotate the various parts of our tank, such controls are not very user friendly. After all, if you did not know they were in the code, how would you ever know to press them without some kind of prompting?
Instead of using keys, we will implement a basic set of user interface controls right on the game screen itself. These will include buttons and text fields, both to provide the player with information about the game and to accept user input and commands.
Even in 3D games, most of the
user interface (UI) elements will be composed of 2D items, so we will return to using SpriteBatch
for the first time since our introduction to XNA in Chapter 1, Introduction to XNA.
In designing our user interface, we know we will need to accomplish two main goals:
Allow each player to aim their cannon and fire at the opponent
Display information about the current aiming values for the cannon, so the player can make the appropriate...