Game Development Reference
In-Depth Information
The player needs more than a field to play; the player also needs to know how
many mines remain. Switch to the Design view of PlayingField . We will drag
four labels to the control panel to help the user:
1. Drag a Label control from the Toolbox and drop it to the right of the Expert
button.
2. Change the Text property to 888 and the Name property to MovesLeftLabel.
3. Change the BorderStyle property to FixedSingle and the TextAlign property
to MiddleCenter.
4. Drag a Label control from the Toolbox and drop it to the right of the
MovesLeftLabel.
5. Change the new label's Text property to Moves Left.
6. Drag a Label control from the Toolbox and drop it below the
MovesLeftLabel.
7. Change the Text property to 999 and the Name property to MinesLeftLabel.
8. Change the BorderStyle property to FixedSingle and the TextAlign property
to MiddleCenter.
9. Drag a Label control from the Toolbox and drop it to the right of the
MinesLeftLabel.
10. Change the Text property to Mines Remaining.
After you open the File menu and choose Save All, your screen should resemble
Figure 4.4.
Now we need to provide the code to update those numbers. Add the following
code to the end of the NewGame routine, just above the code that changes the
cursor back.
'Init the counters
MinesLeftLabel.Text = NumMines.ToString
MovesLeftLabel.Text = sqcnt.ToString
As people manipulate the squares, the squares will need to change the numbers as
well. When a player clicks a square to reveal it, the number of moves remaining
goes down. When the player flags a square, it reduces both the number of moves
 
Search Nedrilad ::




Custom Search