VERSION 5.00 Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX" Begin VB.Form Form1 BackColor = &H00C0FFFF& Caption = "Mastermind" ClientHeight = 7230 ClientLeft = 1740 ClientTop = 930 ClientWidth = 10635 LinkTopic = "Form1" ScaleHeight = 7230 ScaleWidth = 10635 WindowState = 2 'Maximized Begin VB.CommandButton cmdHide Caption = "Hide" Height = 735 Left = 8760 TabIndex = 18 Top = 6480 Visible = 0 'False Width = 1455 End Begin VB.CommandButton cmdGiveUp Caption = "Give Up!" Enabled = 0 'False Height = 495 Left = 7440 TabIndex = 17 Top = 120 Width = 1575 End Begin VB.CommandButton cmdGuess Caption = "Guess" Enabled = 0 'False Height = 735 Left = 6840 TabIndex = 16 Top = 6480 Visible = 0 'False Width = 1815 End Begin VB.TextBox Text1 Enabled = 0 'False BeginProperty Font Name = "Comic Sans MS" Size = 8.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 2175 Left = 6840 MultiLine = -1 'True TabIndex = 15 Top = 4200 Width = 3375 End Begin VB.PictureBox dummyblack BackColor = &H80000009& Enabled = 0 'False Height = 375 Left = 6360 Picture = "mastermind.frx":0000 ScaleHeight = 315 ScaleWidth = 315 TabIndex = 11 Top = 3000 Width = 375 End Begin VB.PictureBox white BackColor = &H80000009& Enabled = 0 'False Height = 375 Left = 6360 Picture = "mastermind.frx":03B6 ScaleHeight = 315 ScaleWidth = 315 TabIndex = 10 Top = 3600 Width = 375 End Begin VB.PictureBox purple BackColor = &H80000009& Enabled = 0 'False Height = 375 Left = 9480 Picture = "mastermind.frx":076C ScaleHeight = 315 ScaleWidth = 315 TabIndex = 8 Top = 1560 Width = 375 End Begin VB.PictureBox orange BackColor = &H80000009& Enabled = 0 'False Height = 375 Left = 9000 Picture = "mastermind.frx":0B3C ScaleHeight = 315 ScaleWidth = 315 TabIndex = 7 Top = 1560 Width = 375 End Begin VB.PictureBox lightblue BackColor = &H80000009& Enabled = 0 'False Height = 375 Left = 8520 Picture = "mastermind.frx":0F02 ScaleHeight = 315 ScaleWidth = 315 TabIndex = 6 Top = 1560 Width = 375 End Begin VB.PictureBox blue BackColor = &H80000009& Enabled = 0 'False Height = 375 Left = 7560 Picture = "mastermind.frx":12B8 ScaleHeight = 315 ScaleWidth = 315 TabIndex = 5 Top = 1560 Width = 375 End Begin VB.PictureBox black BackColor = &H80000009& Enabled = 0 'False Height = 375 Left = 7080 Picture = "mastermind.frx":166E ScaleHeight = 315 ScaleWidth = 315 TabIndex = 4 Top = 1560 Width = 375 End Begin VB.PictureBox green BackColor = &H80000009& Enabled = 0 'False Height = 375 Left = 8040 Picture = "mastermind.frx":1A24 ScaleHeight = 315 ScaleWidth = 315 TabIndex = 3 Top = 1560 Width = 375 End Begin MSFlexGridLib.MSFlexGrid grid Height = 5205 Left = 2040 TabIndex = 0 Top = 2040 Width = 4215 _ExtentX = 7435 _ExtentY = 9181 _Version = 393216 Rows = 21 Cols = 10 FixedRows = 0 GridColor = 255 GridColorFixed = 14737632 Enabled = 0 'False ScrollBars = 2 End Begin VB.Label Label6 BackColor = &H00C0FFFF& Caption = "Correct color, wrong location" BeginProperty Font Name = "Comic Sans MS" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 6960 TabIndex = 14 Top = 3600 Width = 3255 End Begin VB.Label Label5 BackColor = &H00C0FFFF& Caption = "Correct color, correct location" BeginProperty Font Name = "Comic Sans MS" Size = 9.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 375 Left = 6840 TabIndex = 13 Top = 3000 Width = 3255 End Begin VB.Label Label4 Alignment = 2 'Center BackColor = &H00C0FFFF& Caption = "Clues" BeginProperty Font Name = "Comic Sans MS" Size = 15.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 495 Left = 7560 TabIndex = 12 Top = 2160 Width = 1695 End Begin VB.Label Label3 Alignment = 2 'Center BackColor = &H00C0FFFF& Caption = "Choices" BeginProperty Font Name = "Comic Sans MS" Size = 15.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 615 Left = 6960 TabIndex = 9 Top = 840 Width = 2775 End Begin VB.Label Label2 Alignment = 2 'Center BackColor = &H00C0FFFF& Caption = "Code" BeginProperty Font Name = "Comic Sans MS" Size = 15.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 615 Left = 2520 TabIndex = 2 Top = 1320 Width = 1575 End Begin VB.Label Label1 Alignment = 2 'Center BackColor = &H00C0FFFF& Caption = "Clues" BeginProperty Font Name = "Comic Sans MS" Size = 15.75 Charset = 0 Weight = 400 Underline = 0 'False Italic = 0 'False Strikethrough = 0 'False EndProperty Height = 615 Left = 4440 TabIndex = 1 Top = 1320 Width = 1695 End Begin VB.Menu mnuGame Caption = "Game" Begin VB.Menu mnuNewGame Caption = "New Game" End Begin VB.Menu mnuAbout Caption = "About" End Begin VB.Menu mnuQuit Caption = "Quit" End End Begin VB.Menu mnuOpponent Caption = "Opponent" Enabled = 0 'False Begin VB.Menu mnuComputer Caption = "Computer" End Begin VB.Menu mnuPerson Caption = "Person" End End Begin VB.Menu mnuDirections Caption = "Directions" End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Dim Choice As String 'Represents the color chosen Dim Code(4) As String Dim TempCode(4) As String Dim Guess(4) As String Dim NumberTurns As Integer Dim T As Integer Dim NumberCorrect As Integer Dim Person As String Private Sub black_Click() Choice = "black" grid.Enabled = True End Sub Private Sub blue_Click() Choice = "blue" grid.Enabled = True End Sub Private Sub cmdGiveUp_Click() grid.Row = 0 For T = 1 To 4 grid.Col = T Select Case Code(T) Case "black" Set grid.CellPicture = black.Picture Case "orange" Set grid.CellPicture = orange.Picture Case "blue" Set grid.CellPicture = blue.Picture Case "lightblue" Set grid.CellPicture = lightblue.Picture Case "green" Set grid.CellPicture = green.Picture Case "purple" Set grid.CellPicture = purple.Picture End Select Next T MsgBox "Whimp! Hit OK to play again. Your board will be cleared and you may once again select the opponent. Namely, the computer or another person.", vbOKOnly, "Mastermind" mnuNewGame_Click End Sub Private Sub cmdGuess_Click() Text1.Text = "Sorry, you are not correct yet. Try again by placing new choices in the next row." NumberCorrect = 0 grid.Col = 5 For T = 1 To 4 If TempCode(T) = Guess(T) Then TempCode(T) = "" Guess(T) = "1" grid.Col = grid.Col + 1 Set grid.CellPicture = dummyblack.Picture NumberCorrect = NumberCorrect + 1 End If Next T For T = 1 To 4 If TempCode(T) <> "" Then For G = 1 To 4 If TempCode(T) = Guess(G) Then Guess(G) = "1" grid.Col = grid.Col + 1 Set grid.CellPicture = white.Picture Exit For End If Next G End If Next T For T = 1 To 4 Guess(T) = "" Next T For T = 1 To 4 TempCode(T) = Code(T) Next T cmdGuess.Visible = False If NumberCorrect = 4 Then Text1.Text = "You win! Select 'New Game' to play again" grid.Enabled = False cmdGiveUp.Enabled = False Else NumberTurns = NumberTurns + 1 End If End Sub Private Sub Command1_Click() End Sub Private Sub cmdHide_Click() Person = "False" grid.Clear grid.Col = 5 For r = 0 To 20 grid.Row = r grid.CellBackColor = QBColor(7) Next r grid.Row = 0 For c = 1 To 9 grid.Col = c grid.CellBackColor = QBColor(7) Next c grid.Col = 0 grid.Row = 0 grid.ColWidth(0) = 500 grid.Text = "Turn" For x = 1 To 20 grid.Row = x grid.Text = x Next x NumberTurns = 1 cmdHide.Visible = False cmdGiveUp.Enabled = True Text1.Text = "Let the game begin. Your opponent has randomly selected 4 colors and hid them in the top row under the word 'Code'. Your job is to break the code! To begin, click a color from the Choices available, then click on a cell under the 'Code' in row 1." mnuOpponent.Enabled = False End Sub Private Sub Form_Load() grid.Col = 0 grid.Row = 0 grid.ColWidth(0) = 500 grid.Text = "Turn" For x = 1 To 20 grid.Row = x grid.Text = x Next x For c = 1 To 9 grid.ColWidth(c) = 375 Next c For r = 0 To 20 grid.RowHeight(r) = 375 Next r grid.Col = 5 For r = 0 To 20 grid.Row = r grid.CellBackColor = QBColor(7) Next r grid.Row = 0 For c = 1 To 9 grid.Col = c grid.CellBackColor = QBColor(7) Next c Text1.Text = "Select 'Game' then 'New Game' to begin or read the Directions first if you do not know how to play Mastermind." End Sub Private Sub green_Click() Choice = "green" grid.Enabled = True End Sub Private Sub grid_Click() If Person = "True" Then If grid.Row <> 0 Or grid.Col < 1 Or grid.Col > 4 Then Text1.Text = "Sorry, you must put your choice in a legal location!" Else Text1.Text = "Ok, keep selecting colors to create the 'code'." Select Case Choice Case "black" Code(grid.Col) = "black" TempCode(grid.Col) = "black" Set grid.CellPicture = black.Picture Case "blue" Code(grid.Col) = "blue" TempCode(grid.Col) = "blue" Set grid.CellPicture = blue.Picture Case "green" Set grid.CellPicture = green.Picture Code(grid.Col) = "green" TempCode(grid.Col) = "green" Case "lightblue" Set grid.CellPicture = lightblue.Picture Code(grid.Col) = "lightblue" TempCode(grid.Col) = "lightblue" Case "orange" Set grid.CellPicture = orange.Picture Code(grid.Col) = "orange" TempCode(grid.Col) = "orange" Case "purple" Set grid.CellPicture = purple.Picture Code(grid.Col) = "purple" TempCode(grid.Col) = "purple" End Select End If If Code(1) <> "" And Code(2) <> "" And Code(3) <> "" And Code(4) <> "" Then cmdHide.Visible = True Text1.Text = "Hit 'Hide' when you are done. You may change some of your settings now." End If Else If grid.Row <> NumberTurns Or grid.Col < 1 Or grid.Col > 4 Then Text1.Text = "Sorry, you must put your choice in a legal location!" Else Text1.Text = "Ok! Now continue selecting colors. When you are happy with your four choices, you will be allowed to 'guess' and clues will be given." Select Case Choice Case "black" Set grid.CellPicture = black.Picture Guess(grid.Col) = "black" Case "blue" Set grid.CellPicture = blue.Picture Guess(grid.Col) = "blue" Case "green" Set grid.CellPicture = green.Picture Guess(grid.Col) = "green" Case "lightblue" Set grid.CellPicture = lightblue.Picture Guess(grid.Col) = "lightblue" Case "orange" Set grid.CellPicture = orange.Picture Guess(grid.Col) = "orange" Case "purple" Set grid.CellPicture = purple.Picture Guess(grid.Col) = "purple" End Select End If If Guess(1) <> "" And Guess(2) <> "" And Guess(3) <> "" And Guess(4) <> "" Then Text1.Text = "You can hit 'Guess' now or continue to choose" cmdGuess.Enabled = True cmdGuess.Visible = True End If End If End Sub Private Sub lightblue_Click() Choice = "lightblue" grid.Enabled = True End Sub Private Sub mnuAbout_Click() MsgBox "This Mastermind game was written by the Visual Basic 6.0 programming class at Berlin High School, Berlin NH during the first semester of the 1998-99 school year. Mr. Sweeny (sweeny@ncia.net) was the instructor. Enjoy!", vbOKOnly, "About Mastermind" End Sub Private Sub mnuComputer_Click() Randomize cmdGiveUp.Enabled = True Person = "False" mnuOpponent.Enabled = False Text1.Text = "The computer randomly selected 4 colors and hid them in the top row under the word 'Code'. Your job is to break the code! To begin, click a color from the Choices available, then click on a cell under the 'Code' in row 1." grid.Row = 0 For x = 1 To 4 grid.Col = x r = Int(Rnd * 6 + 1) Select Case r Case 1 Code(x) = "black" TempCode(x) = "black" 'Set grid.CellPicture = black.Picture Case 2 Code(x) = "blue" TempCode(x) = "blue" 'Set grid.CellPicture = blue.Picture Case 3 Code(x) = "green" TempCode(x) = "green" 'Set grid.CellPicture = green.Picture Case 4 Code(x) = "lightblue" TempCode(x) = "lightblue" 'Set grid.CellPicture = lightblue.Picture Case 5 Code(x) = "orange" TempCode(x) = "orange" 'Set grid.CellPicture = orange.Picture Case 6 Code(x) = "purple" TempCode(x) = "purple" 'Set grid.CellPicture = purple.Picture End Select Next x ' Enable the Choices black.Enabled = True blue.Enabled = True orange.Enabled = True lightblue.Enabled = True purple.Enabled = True green.Enabled = True grid.Enabled = False NumberTurns = 1 For x = 1 To 4 Guess(x) = "" Next x End Sub Private Sub mnuDirections_Click() MsgBox "In this version of Mastermind you may play against the computer or another person. The computer or the other person selects four of the six color choices available(a color may be selected more than once) and places them in the top row under 'Code' and hides them from you. Your job is to 'break the code' by selecting colors from the choices and placing them in the rows available under 'Code'. You use the mouse for this. That is, you click on a color choice, then on the spot where you want to place it. After making your four choices you can click on 'Guess' and clues will then be given in the adjacent row informing you how you did. You may give up at any time by clicking on the Give Up button. To begin, click on Game, then New Game. After that you can select an opponent(computer or another person).", vbOKOnly, "Mastermind" End Sub Private Sub mnuNewGame_Click() cmdGiveUp.Enabled = False mnuOpponent.Enabled = True ' step one...clear the grid grid.Clear grid.Col = 0 grid.Row = 0 grid.ColWidth(0) = 500 grid.Text = "Turn" For x = 1 To 20 grid.Row = x grid.Text = x Next x For c = 1 To 9 grid.ColWidth(c) = 375 Next c For r = 0 To 20 grid.RowHeight(r) = 375 Next r grid.Col = 5 For r = 0 To 20 grid.Row = r grid.CellBackColor = QBColor(7) Next r grid.Row = 0 For c = 1 To 9 grid.Col = c grid.CellBackColor = QBColor(7) Next c Text1.Text = "Welcome to Mastermind! To begin the game click on Opponent and choose the Computer or another Person to play against." mnuOpponent.Enabled = True grid.Enabled = False End Sub Private Sub mnuPerson_Click() Text1.Text = "Create the 'code' for your opponent by choosing colors from the 'Choices' by clicking on them. Then click on the first row under 'Code' to place your selections. Hit 'Hide' when you are happy with your code." For x = 1 To 4 Code(x) = "" TempCode(x) = "" Next x grid.Row = 0 Person = "True" grid.Enabled = True ' Enable the Choices black.Enabled = True blue.Enabled = True orange.Enabled = True lightblue.Enabled = True purple.Enabled = True green.Enabled = True grid.Enabled = False End Sub Private Sub mnuQuit_Click() MsgBox "Thank you for playing Mastermind!" End End Sub Private Sub orange_Click() Choice = "orange" grid.Enabled = True End Sub Private Sub purple_Click() Choice = "purple" grid.Enabled = True End Sub