?? nim.frm
字號:
blnWon = True
cmdOkMove.Visible = False
For intLoop = 0 To 3
For intLoop1 = mintRow(intLoop) To 6
If intLoop = 0 Then
imgRow0(intLoop1).Visible = False
ElseIf intLoop = 1 Then
imgRow1(intLoop1).Visible = False
ElseIf intLoop = 2 Then
imgRow2(intLoop1).Visible = False
ElseIf intLoop = 3 Then
imgRow3(intLoop1).Visible = False
End If
Next intLoop1
Next intLoop
For intLoop = 0 To 6
If imgRow0(intLoop).Visible = True Then
blnWon = False
ElseIf imgRow1(intLoop).Visible = True Then
blnWon = False
ElseIf imgRow2(intLoop).Visible = True Then
blnWon = False
ElseIf imgRow3(intLoop).Visible = True Then
blnWon = False
End If
Next intLoop
If blnWon = True Then
Call CompWon
Else
mblnUserGo = True
lblTurn.Caption = "Your Turn."
End If
End Sub
Private Sub Form_Load()
'TURN ON THE MUSIC
mlngReturn = mciSendString("Close all", 0&, 0, 0)
mstrMusic = "open " & App.Path & "\Simpsons.mid" & " type sequencer alias music"
mlngReturn = mciSendString(mstrMusic, 0&, 0, 0)
mlngReturn = mciSendString("play music", 0&, 0, 0)
mblnUserGo = False
Randomize
End Sub
Private Sub Form_Unload(Cancel As Integer)
mlngReturn = mciSendString("Close all", 0&, 0, 0)
End
End Sub
'User Clicks On Row 0
Private Sub imgRow0_Click(Index As Integer)
Dim intLoop As Integer
Dim blnWon1 As Boolean
blnWon1 = False
If mblnUserGo Then
For intLoop = Index To 6
imgRow0(intLoop).Visible = False
Next intLoop
mblnUserGo = False
blnWon1 = ChekUserWon(False)
If blnWon1 = True Then
Exit Sub
Else: Call CompsGo
End If
End If
End Sub
'User Clicks On Row 1
Private Sub imgRow1_Click(Index As Integer)
Dim intLoop As Integer
Dim blnWon1 As Boolean
blnWon1 = False
If mblnUserGo Then
For intLoop = Index To 6
imgRow1(intLoop).Visible = False
Next intLoop
mblnUserGo = False
blnWon1 = ChekUserWon(False)
If blnWon1 = True Then
Exit Sub
Else: Call CompsGo
End If
End If
End Sub
'User Clicks On Row 2
Private Sub imgRow2_Click(Index As Integer)
Dim intLoop As Integer
Dim blnWon1 As Boolean
blnWon1 = False
If mblnUserGo Then
For intLoop = Index To 6
imgRow2(intLoop).Visible = False
Next intLoop
mblnUserGo = False
blnWon1 = ChekUserWon(False)
If blnWon1 = True Then
Exit Sub
Else: Call CompsGo
End If
End If
End Sub
'User Clicks On Row 3
Private Sub imgRow3_Click(Index As Integer)
Dim intLoop As Integer
Dim blnWon1 As Boolean
blnWon1 = False
If mblnUserGo Then
For intLoop = Index To 6
imgRow3(intLoop).Visible = False
Next intLoop
mblnUserGo = False
blnWon1 = ChekUserWon(False)
If blnWon1 = True Then
Exit Sub
Else: Call CompsGo
End If
End If
End Sub
Private Sub mnuGameExit_Click()
End
End Sub
Private Sub CompsGo()
Dim intLoop As Integer, intLoop1 As Integer, intLoop2 As Integer
Dim mintMatrix() As Integer
ReDim mintRow(3) 'RESET THESE ARRAYS
ReDim mintMatrix(4, 2)
ReDim mintOldmIntRow(3)
For intLoop = 0 To 6 'DEFINE HOW MANY IMAGES IN THAT ROW
If imgRow0(intLoop).Visible = True Then
mintRow(0) = mintRow(0) + 1
End If
If imgRow1(intLoop).Visible = True Then
mintRow(1) = mintRow(1) + 1
End If
If imgRow2(intLoop).Visible = True Then
mintRow(2) = mintRow(2) + 1
End If
If imgRow3(intLoop).Visible = True Then
mintRow(3) = mintRow(3) + 1
End If
Next intLoop
For intLoop = 0 To 3 'SET UP THE DIGITAL SUM
Select Case mintRow(intLoop)
Case 1
mintMatrix(intLoop, 2) = 1
Case 2
mintMatrix(intLoop, 1) = 1
Case 3
mintMatrix(intLoop, 1) = 1
mintMatrix(intLoop, 2) = 1
Case 4
mintMatrix(intLoop, 0) = 1
Case 5
mintMatrix(intLoop, 0) = 1
mintMatrix(intLoop, 2) = 1
Case 6
mintMatrix(intLoop, 0) = 1
mintMatrix(intLoop, 1) = 1
Case 7
mintMatrix(intLoop, 0) = 1
mintMatrix(intLoop, 1) = 1
mintMatrix(intLoop, 2) = 1
End Select
Next intLoop
mintMatrix(4, 0) = mintMatrix(0, 0) + mintMatrix(1, 0) + mintMatrix(2, 0) + mintMatrix(3, 0)
mintMatrix(4, 1) = mintMatrix(0, 1) + mintMatrix(1, 1) + mintMatrix(2, 1) + mintMatrix(3, 1)
mintMatrix(4, 2) = mintMatrix(0, 2) + mintMatrix(1, 2) + mintMatrix(2, 2) + mintMatrix(3, 2)
'SET HOW MANY NUMBERS IN EACH ROW IN ORDER TO UNDRAW THEM LATER
For intLoop = 0 To 3
mintOldmIntRow(intLoop) = mintRow(intLoop)
Next intLoop
'IF FIRST NUMBER IN ROW 4 IS ODD
If mintMatrix(4, 0) = 1 Or mintMatrix(4, 0) = 3 Then
'ROW 3
If mintMatrix(3, 0) = 1 Then
mintRow(3) = mintRow(3) - 4
If mintMatrix(4, 1) = 1 Or mintMatrix(4, 1) = 3 Then
If mintMatrix(3, 1) = 1 Then
mintRow(3) = mintRow(3) - 2
Else: mintRow(3) = mintRow(3) + 2
End If
End If
If mintMatrix(4, 2) = 1 Or mintMatrix(4, 2) = 3 Then
If mintMatrix(3, 2) = 1 Then
mintRow(3) = mintRow(3) - 1
Else: mintRow(3) = mintRow(3) + 1
End If
End If
'ROW 2
ElseIf mintMatrix(2, 0) = 1 Then
mintRow(2) = mintRow(2) - 4
If mintMatrix(4, 1) = 1 Or mintMatrix(4, 1) = 3 Then
If mintMatrix(2, 1) = 1 Then
mintRow(2) = mintRow(2) - 2
Else: mintRow(2) = mintRow(2) + 2
End If
End If
If mintMatrix(4, 2) = 1 Or mintMatrix(4, 2) = 3 Then
If mintMatrix(2, 2) = 1 Then
mintRow(2) = mintRow(2) - 1
Else: mintRow(2) = mintRow(2) + 1
End If
End If
'ROW 1
ElseIf mintMatrix(1, 0) = 1 Then
mintRow(1) = mintRow(1) - 4
If mintMatrix(4, 1) = 1 Or mintMatrix(4, 1) = 3 Then
If mintMatrix(1, 1) = 1 Then
mintRow(1) = mintRow(1) - 2
Else: mintRow(1) = mintRow(1) + 2
End If
End If
If mintMatrix(4, 2) = 1 Or mintMatrix(4, 2) = 3 Then
If mintMatrix(1, 2) = 1 Then
mintRow(1) = mintRow(1) - 1
Else: mintRow(1) = mintRow(1) + 1
End If
End If
'ROW 0
ElseIf mintMatrix(0, 0) = 1 Then
mintRow(0) = mintRow(0) - 4
If mintMatrix(4, 1) = 1 Or mintMatrix(4, 1) = 3 Then
If mintMatrix(0, 1) = 1 Then
mintRow(0) = mintRow(0) - 2
Else: mintRow(0) = mintRow(0) + 2
End If
End If
If mintMatrix(4, 2) = 1 Or mintMatrix(4, 2) = 3 Then
If mintMatrix(0, 2) = 1 Then
mintRow(0) = mintRow(0) - 1
Else: mintRow(0) = mintRow(0) + 1
End If
End If
End If
'SECOND NUMBER IS ODD
ElseIf mintMatrix(4, 1) = 1 Or mintMatrix(4, 1) = 3 Then
'ROW 3
If mintMatrix(3, 1) = 1 Then
mintRow(3) = mintRow(3) - 2
If mintMatrix(4, 2) = 1 Or mintMatrix(4, 2) = 3 Then
If mintMatrix(3, 2) = 1 Then
mintRow(3) = mintRow(3) - 1
Else: mintRow(3) = mintRow(3) + 1
End If
End If
'ROW 2
ElseIf mintMatrix(2, 1) = 1 Then
mintRow(2) = mintRow(2) - 2
If mintMatrix(4, 2) = 1 Or mintMatrix(4, 2) = 3 Then
If mintMatrix(2, 2) = 1 Then
mintRow(2) = mintRow(2) - 1
Else: mintRow(2) = mintRow(2) + 1
End If
End If
'ROW 1
ElseIf mintMatrix(1, 1) = 1 Then
mintRow(1) = mintRow(1) - 2
If mintMatrix(4, 2) = 1 Or mintMatrix(4, 2) = 3 Then
If mintMatrix(1, 2) = 1 Then
mintRow(1) = mintRow(1) - 1
Else: mintRow(1) = mintRow(1) + 1
End If
End If
'ROW 0
ElseIf mintMatrix(0, 1) = 1 Then
mintRow(0) = mintRow(0) - 2
If mintMatrix(4, 2) = 1 Or mintMatrix(4, 2) = 3 Then
If mintMatrix(0, 2) = 1 Then
mintRow(0) = mintRow(0) - 1
Else: mintRow(0) = mintRow(0) + 1
End If
End If
End If
'THIRD NUMBER IS ODD
ElseIf mintMatrix(4, 2) = 1 Or mintMatrix(4, 2) = 3 Then
'ROW 1
If mintMatrix(3, 2) = 1 Then
mintRow(3) = mintRow(3) - 1
ElseIf mintMatrix(2, 2) = 1 Then
mintRow(2) = mintRow(2) - 1
ElseIf mintMatrix(1, 2) = 1 Then
mintRow(1) = mintRow(1) - 1
ElseIf mintMatrix(0, 2) = 1 Then
mintRow(0) = mintRow(0) - 1
End If
'THE USER IS WINING...CHOOSE THE BOTTOM IMGAGE TO TAKE OUT
Else
For intLoop = 3 To 0 Step -1
If mintRow(intLoop) > 0 Then
mintRow(intLoop) = mintRow(intLoop) - 1
Call unDraw
Exit Sub
End If
Next intLoop
End If
Call unDraw
End Sub
'UNDRAW THE THE COMPS DECISION
Private Sub unDraw()
Dim intLoopCompTakes As Integer, intNumber2Take
Dim strCompTake As String, strPlural As String
For intLoopCompTakes = 0 To 3
If mintRow(intLoopCompTakes) <> mintOldmIntRow(intLoopCompTakes) Then
strCompTake = Choose(intLoopCompTakes + 1, "Snatch ", "Grab ", "Steal ", "Take ")
intNumber2Take = (mintOldmIntRow(intLoopCompTakes) - mintRow(intLoopCompTakes))
If intNumber2Take > 1 Then
strPlural = "s"
Else: strPlural = ""
End If
lblTurn.Caption = "I Will " & strCompTake & intNumber2Take & " Bart" & strPlural & " Out Of Row " & intLoopCompTakes + 1
cmdOkMove.Visible = True
End If
Next intLoopCompTakes
End Sub
'COMPUTER WON...TIME TO GLOAT
Private Sub CompWon()
Dim strGloat As String
Dim intIndex As Integer
imgCompWins.Visible = True
intIndex = Int(5 * Rnd) + 1
strGloat = Choose(intIndex, "I kicked your butt!", "Cool Man!...I win.", "You need to improve your logic...I WIN!", "Keep on tryin....I WIN!", "Ha ha ha...I win, you can't match this logic!")
lblTurn.Caption = strGloat
End Sub
'CHECK TO SEE IF THE USER WON AND DISPLAY THE APPROPRIATE MESSAGE
Private Function ChekUserWon(blnWon As Boolean)
Dim intLoop As Integer, intIndex As Integer
Dim strUserWon As String
blnWon = True
For intLoop = 0 To 6
If imgRow0(intLoop).Visible = True Then
blnWon = False
ElseIf imgRow1(intLoop).Visible = True Then
blnWon = False
ElseIf imgRow2(intLoop).Visible = True Then
blnWon = False
ElseIf imgRow3(intLoop).Visible = True Then
blnWon = False
End If
Next intLoop
If blnWon = True Then
imgUserWins.Visible = True
intIndex = Int(5 * Rnd) + 1
strUserWon = Choose(intIndex, "Eat My Shorts", "Kiss My Butt", "Get Bent", "Don't Have a Cow Man, You Only Won ONCE!", "AYCARUMBA, YOU WON!")
lblTurn.Caption = "You Won!" & vbCrLf & strUserWon
blnWon = True
Else: blnWon = False
End If
End Function
Private Sub mnuGameNewGame_Click()
Dim intLoop As Integer, intRow As Integer, intIconNumber(4) As Integer
Dim intUserTurn As Integer
lblTurn.Caption = ""
imgCompWins.Visible = False
imgUserWins.Visible = False
ReDim mintRow(3)
ReDim mintMatrix(4, 2)
For intLoop = 1 To 6 'Turn not visible all the images
imgRow0(intLoop).Visible = False
imgRow1(intLoop).Visible = False
imgRow2(intLoop).Visible = False
imgRow3(intLoop).Visible = False
DoEvents
Next intLoop
'Make visible the new game
For intLoop = 0 To Int(Rnd * 6) + 1
imgRow0(intLoop).Visible = True
mintRow(0) = mintRow(0) + 1
Next intLoop
For intLoop = 0 To Int(Rnd * 6) + 1
imgRow1(intLoop).Visible = True
mintRow(1) = mintRow(1) + 1
Next intLoop
For intLoop = 0 To Int(Rnd * 6) + 1
imgRow2(intLoop).Visible = True
mintRow(2) = mintRow(2) + 1
Next intLoop
For intLoop = 0 To Int(Rnd * 6) + 1
imgRow3(intLoop).Visible = True
mintRow(3) = mintRow(3) + 1
Next intLoop
'Determine who goes first - comp/user
intUserTurn = MsgBox("Would you like to go first?", vbYesNo, "Wanna Go")
If intUserTurn = 6 Then '6 Is the Int for the YES button
mblnUserGo = True
lblTurn.Caption = "Your Turn."
ElseIf intUserTurn = 7 Then '7 is the int for the NO button
mblnUserGo = False
Call CompsGo
End If
End Sub
Private Sub mnuHelpAboutBartNIM_Click()
frmAbout.Show
End Sub
Private Sub mnuHelpHowToPlay_Click()
frmHelp.Show
End Sub
Private Sub mnuSoundOff_Click()
mlngReturn = mciSendString("Close all", 0&, 0, 0)
mnuSoundOff.Checked = True
mnuSoundOn.Checked = False
End Sub
Private Sub mnuSoundOn_Click()
'Turn On the Music
mnuSoundOff.Checked = False
mnuSoundOn.Checked = True
mlngReturn = mciSendString("Close all", 0&, 0, 0)
mstrMusic = "open " & App.Path & "\Simpsons.mid" & " type sequencer alias music"
mlngReturn = mciSendString(mstrMusic, 0&, 0, 0)
mlngReturn = mciSendString("play music", 0&, 0, 0)
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -