Game Development Reference
In-Depth Information
Private Sub FaHButton_MouseDown(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
'Our parent is the board.
Dim MainForm As Board = CType(Me.Parent, Board)
'Get the game state from the board so we can ask it things.
Dim GS As GameState = MainForm.CurrentGame
Debug.WriteLine("Mouse Down " & MySubscript.ToString)
'Is the fox on my square?
If MySubscript = GS.FoxAt Then
'Use -1 to signal that it is the fox.
HoundNumber = -1
'Tell Windows we want to do drag/drop.
Call DoDragDrop(Me, DragDropEffects.Move)
Debug.WriteLine("DragDrop FOx")
End If
Dim i As Integer
'Ask gamestate where the hounds are.
Dim Hounds() As Integer = GS.HoundsAt()
'Is a hound on my square?
Fori=0To3
If MySubscript = Hounds(i) Then
'Record which hound is moving.
HoundNumber = i
'Tell Windows we want to drag/drop.
Call DoDragDrop(Me, DragDropEffects.Move)
Debug.WriteLine("DragDrop a Hound")
End If
Next
End Sub
The debug statements provide text that we can follow in the output window when
we run the debugger. You can comment them out or uncomment them to provide
the right level of detail. That handles mouse down. We want to provide feedback as
the mouse travels over the other buttons. Add the following code to the class:
Private Sub FaHButton_DragOver(ByVal sender As Object, ByVal e As System.
Windows.Forms.DragEventArgs) Handles Me.DragOver
'Debug.WriteLine("FaH DragOver")
 
Search Nedrilad ::




Custom Search