Page 1
Page 2
Page 3
Page 4
If we RECEIVE OXWIN, it means we have
lost! We still need to draw the appropriate picture, keep
the score, and in this case play Homer saying Doh. We also
start the reset timer. This is set to five seconds, and
when it fires we reset the game so:-
Private Sub reset_game()
Dim i As Integer
For i = 0 To 8
OXArray(i) = 0
xdisp(i).Picture = ""
Next
If bMyGo Then
bMyGo = True
bReady = True
bHasWon = False
lstStatus.AddItem "Game Reset.", 0
lstStatus.AddItem "Your Go", 0
Else
bMyGo = False
bReady = True
bHasWon = False
lstStatus.AddItem "Game Reset.", 0
lstStatus.AddItem opponentName & _
"'s Go", 0
End If
End Sub
We clear all the pictures (xdisp(i).picture
= ""), change the start player, and re-initialise
any flags set.
The finished screen looks like this:-

There are various improvements that
can be made such as storing the opponents PC names, and
bringing them back into a combo-box for selection, or capturing
mousedown events and actually drawing the 'o' and 'x' characters.
The main purpose of this article was
to illustrate using the Winsock control on IRDA sockets
to produce a 2 player game, and perhaps it is easier to
look at some of the code than to follow some of my attempted
explanations. The full downloadable project uses several
techniques from earlier articles on devBuzz such as the
control array, and the use of frames.
As a conclusion, I think the exchange
of ideas on devBuzz
between developers is tremendous, and has helped me greatly
in the creation of several projects. I think Derek's site
is doing a great job for eVB developer exchange, and he
should be congratulated on a job well done.
For more information on using sockets
on eVB, see my earlier articles, or have a look at http://www.gui-innovations.com.
Previous Page