Game Development Reference
In-Depth Information
'We do NOT color. The caller will want to move stuff
'and after the move, it will call color.
End Sub
We will not call this New method directly from the outside. Instead, we will provide
an interface based on the idea of making a move. The fox is slightly simpler since
there is only one. Add the following code to the Public Methods region:
'So what do we get if the fox moves to some square?
Public Function ProposeFoxTo(ByVal targetSqaure As Integer) As GameState
'Clone me.
Dim afterMove As GameState = New GameState(Me)
'Take a turn . . .
afterMove.Turn = afterMove.Turn + 1
'...bymoving the fox.
afterMove.Fox = targetSqaure
'Analyze the new board.
afterMove.ColorMe()
Return afterMove
End Function
The only difference when moving a hound is that we have to say which hound
moved. Add the following code to the Public Methods region:
'So what do we get if a hound moves to a new square?
Public Function ProposeHoundTo(ByVal houndNumber As Integer, _
ByVal targetSqaure As Integer) As GameState
'Clone me.
Dim afterMove As GameState = New GameState(Me)
'Take a turn . . .
afterMove.Turn = afterMove.Turn + 1
'...bymoving one of the hounds.
afterMove.Hounds(houndNumber) = targetSqaure
'Analyze the new board.
afterMove.ColorMe()
Return afterMove
End Function
Drag and Drop in the Button Class
We finally have enough support from the board and the game state to actually
make some moves. Now we will do the three parts to the drag and drop: the
mouse down, the drag over, and the drop. Change to the FaHButton.vb tab in the
editor. We start with the mouse down event. Add the following code to the class:
 
Search Nedrilad ::




Custom Search