Running the Game

When the user clicks the command button to start the game, the Command1_Click event will be triggered, as shown in Listing 14.11.

Listing 14.11: Command1_Click Event in I’m Thinking of a Color

Private Sub Command1_Click()
Dim i As Integer
Randomize
If Not PlayerInitialized Then
   PlayerInit
End If
If Check1.Value = 0 Then
   PlayerWelcome
Else
   PlayerWelcomeQuick
End If
For i = 1 To 3
   PlayGame (i)
Next i
If Check1.Value = 0 Then
   PlayerByeBye
Else
   PlayerByeByeQuick
End If
End Sub

This routine is in overall control of the game. It begins by initializing the Agent characters if necessary. Then it plays either the long welcome message or the short message, depending on the state of the Check1 check box. This feature helps me test the game while preserving all of the fun interactions.

After the welcome message is displayed, three individual games are played (though in hindsight, rounds would have been a better term). Then I play the appropriate “bye bye” message when the games are finished. To play again, the user clicks the command button.

© 1998 SYBEX Inc. All rights reserved.