Game Development Reference
In-Depth Information
If contents <> HiddenValue.Mine Then
Me.Text = actualNearMines.ToString
End If
'End debugging code
End Sub
There is an easy way to comment out a block of lines: Highlight the lines you
want to make into comments and then hover your mouse over the buttons in the
toolbar below the Data and Tools main menu. You are looking for the ones with
horizontal black lines and blue lines. The tooltip will indicate which button
comments out the lines and which button uncomments the lines. Try them out
and watch what they do to your code. Commenting a comment line adds another
leading ' character to any that are already there. That way, when you uncomment
a block that includes comment lines, the comment lines stay comments.
Our Square objects are ready to be initialized by the form, but they do not yet ask
the form to do so. Click the left drop-down list at the top of the Editing pane.
This one probably has a current value of Square in bold text. Select (Square
Events), which is marked with a lightning bolt. From the right drop-down list,
select the Click event; VB will give you the skeleton of the event handler. Add
code to the event handler so that it looks like the following:
Private Sub Square_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Click
'We should be part of a playing field
Dim theField As PlayingField = Me.Parent
'If not, we can't ask it anything
If theField Is Nothing Then Exit Sub
'If this square is uninitialized, all of them are
If contents = HiddenValue.Uninitialized Then
'Have the playing field object init all the squares
Call theField.InitializeSquares(Row, Col)
End If
'Make the button look pressed
FlatStyle = Windows.Forms.FlatStyle.Flat
Me.BackColor = Color.LightGray
'Below here is where the player finds out if it is safe or not
End Sub
 
Search Nedrilad ::




Custom Search