2个回答
展开全部
Private n(3), m(3) As Integer 'n(3)记录游戏区的四个活动方块的编号
'm(3)记录预览区的四个活动方块的编号
Private situation, situation2, linenum, t As Integer 'situation记录游戏区的方块样式
'situation2记录预览区的方块样式
'linenum记录一次消除的行数
Private Sub hidefang(a As Integer) '定义使方块不可见的过程
Select Case a
Case 0 'a=0使游戏区方块不可见
cmdfang(n(0)).Visible = False
cmdfang(n(1)).Visible = False
cmdfang(n(2)).Visible = False
cmdfang(n(3)).Visible = False
Case 1 'a=1使预览区方块不可见
cmdfangnext(m(0)).Visible = False
cmdfangnext(m(1)).Visible = False
cmdfangnext(m(2)).Visible = False
cmdfangnext(m(3)).Visible = False
End Select
End Sub
Private Sub showfang(a As Integer) '定义使方块可见的过程
Select Case a
Case 0 'a=0使游戏区方块可见
cmdfang(n(0)).Visible = True
cmdfang(n(1)).Visible = True
cmdfang(n(2)).Visible = True
cmdfang(n(3)).Visible = True
Case 1 'a=1使预览区方块不可见
cmdfangnext(m(0)).Visible = True
cmdfangnext(m(1)).Visible = True
cmdfangnext(m(2)).Visible = True
cmdfangnext(m(3)).Visible = True
End Select
End Sub
Private Sub clearline() '定义消除整行的过程
For i = 190 To 10 Step -10
If cmdfang(i).Visible = True And _
cmdfang(i + 1).Visible = True And _
cmdfang(i + 2).Visible = True And _
cmdfang(i + 3).Visible = True And _
cmdfang(i + 4).Visible = True And _
cmdfang(i + 5).Visible = True And _
cmdfang(i + 6).Visible = True And _
cmdfang(i + 7).Visible = True And _
cmdfang(i + 8).Visible = True And _
cmdfang(i + 9).Visible = True Then
For j = i + 4 To i Step -1
t = 1
cmdfang(j).Visible = False
cmdfang(2 * i + 9 - j).Visible = False
For k = 1 To 4000
DoEvents
Next
t = 0
Next
linenum = linenum + 1
For j = i - 1 To 0 Step -1
If cmdfang(j).Visible = True Then
cmdfang(j).Visible = False
cmdfang(j + 10).Visible = True
End If
Next
clearline '为了实现连消数行,这里使用递归调用
End If
Next
End Sub
Private Function downable() As Boolean '自定义函数,确定方块是否能下降
If n(0) < 190 And n(1) < 190 And n(2) < 190 And n(3) < 190 Then
If cmdfang(n(0) + 10).Visible = False And _
cmdfang(n(1) + 10).Visible = False And _
cmdfang(n(2) + 10).Visible = False And _
cmdfang(n(3) + 10).Visible = False Then
downable = True
Else
downable = False
End If
Else
downable = False
End If
End Function
Private Function leftable() As Boolean '自定义函数,确定方块是否能左移
If n(0) Mod 10 <> 0 And n(1) Mod 10 <> 0 And n(2) Mod 10 <> 0 And n(3) Mod 10 <> 0 Then
If cmdfang(n(0) - 1).Visible = False And _
cmdfang(n(1) - 1).Visible = False And _
cmdfang(n(2) - 1).Visible = False And _
cmdfang(n(3) - 1).Visible = False Then
leftable = True
Else
leftable = False
End If
Else
leftable = False
End If
End Function
Private Function rightable() As Boolean '自定义函数,确定方块是否能右移
If n(0) Mod 10 <> 9 And n(1) Mod 10 <> 9 And n(2) Mod 10 <> 9 And n(3) Mod 10 <> 9 Then
If cmdfang(n(0) + 1).Visible = False And _
cmdfang(n(1) + 1).Visible = False And _
cmdfang(n(2) + 1).Visible = False And _
cmdfang(n(3) + 1).Visible = False Then
rightable = True
Else
rightable = False
End If
Else
rightable = False
End If
End Function
Private Sub loadfangkuai() '定义随机产生一种方块的过程
Select Case Int(Rnd * 6)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 0 '这是长条型方块
Select Case Int(Rnd * 2)
Case 0
m(0) = 3
m(1) = 4
m(2) = 5
m(3) = 6
situation2 = 0
Case 1
m(0) = 5
m(1) = 15
m(2) = 25
m(3) = 35
situation2 = 1
End Select
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 1 '这是正方形方块
m(0) = 4
m(1) = 5
m(2) = 14
m(3) = 15
situation2 = 2
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 2 '这是正S型方块
Select Case Int(Rnd * 2)
Case 0
m(0) = 6
m(1) = 5
m(2) = 15
m(3) = 14
situation2 = 3
Case 1
m(0) = 4
m(1) = 14
m(2) = 15
m(3) = 25
situation2 = 4
End Select
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 3 '这是反S型方块
Select Case Int(Rnd * 2)
Case 0
m(0) = 4
m(1) = 5
m(2) = 15
m(3) = 16
situation2 = 5
Case 1
m(0) = 5
m(1) = 15
m(2) = 14
m(3) = 24
situation2 = 6
End Select
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 4 '这是T型方块
Select Case Int(Rnd * 4)
Case 0
m(0) = 4
m(1) = 5
m(2) = 6
m(3) = 15
situation2 = 7
Case 1
m(0) = 5
m(1) = 15
m(2) = 25
m(3) = 14
situation2 = 8
Case 2
m(0) = 16
m(1) = 15
m(2) = 14
m(3) = 5
situation2 = 9
Case 3
m(0) = 24
m(1) = 14
m(2) = 4
m(3) = 15
situation2 = 10
End Select
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 5 '这是正7字型方块
Select Case Int(Rnd * 4)
Case 0
m(0) = 4
m(1) = 5
m(2) = 15
m(3) = 25
situation2 = 11
Case 1
m(0) = 5
m(1) = 15
m(2) = 14
m(3) = 13
situation2 = 12
Case 2
m(0) = 25
m(1) = 24
m(2) = 14
m(3) = 4
situation2 = 13
Case 3
m(0) = 14
m(1) = 4
m(2) = 5
m(3) = 6
situation2 = 14
End Select
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 6 '这是反7字型方块
Select Case Int(Rnd * 4)
Case 0
m(0) = 5
m(1) = 4
m(2) = 14
m(3) = 24
situation2 = 15
Case 1
m(0) = 15
m(1) = 5
m(2) = 4
m(3) = 3
situation2 = 16
Case 2
m(0) = 24
m(1) = 25
m(2) = 15
m(3) = 5
situation2 = 17
Case 3
m(0) = 4
m(1) = 14
m(2) = 15
m(3) = 16
situation2 = 18
End Select
End Select
End Sub
Private Sub zhuan() '定义使方块旋转的过程
Select Case situation
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 0 '这是长条型方块
If n(0) - 18 >= 2 And n(3) + 9 <= 198 Then
If cmdfang(n(0) - 18).Visible = False And _
cmdfang(n(1) - 9).Visible = False And _
cmdfang(n(3) + 9).Visible = False Then
hidefang 0
n(0) = n(0) - 18
n(1) = n(1) - 9
n(3) = n(3) + 9
showfang 0
situation = 1
End If
End If
Case 1
If (n(0) + 18) Mod 10 < 8 And (n(3) - 9) Mod 10 > 0 Then
If cmdfang(n(0) + 18).Visible = False And _
cmdfang(n(1) + 9).Visible = False And _
cmdfang(n(3) - 9).Visible = False Then
hidefang 0
n(0) = n(0) + 18
n(1) = n(1) + 9
n(3) = n(3) - 9
showfang 0
situation = 0
End If
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 2 '这是正方形方块
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 3 '这是正S型方块
If n(0) - 11 > 1 Then
If cmdfang(n(0) - 11).Visible = False And _
cmdfang(n(3) + 2).Visible = False Then
hidefang 0
n(0) = n(0) - 11
n(2) = n(2) - 9
n(3) = n(3) + 2
showfang 0
situation = 4
End If
End If
Case 4
If (n(3) - 2) Mod 10 < 9 Then
If cmdfang(n(2) + 9).Visible = False And _
cmdfang(n(3) - 2).Visible = False Then
hidefang 0
n(0) = n(0) + 11
n(2) = n(2) + 9
n(3) = n(3) - 2
showfang 0
situation = 3
End If
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 5 '这是反S型方块
If n(0) - 9 > 1 Then
If cmdfang(n(0) - 9).Visible = False And _
cmdfang(n(3) - 2).Visible = False Then
hidefang 0
n(0) = n(0) - 9
n(2) = n(2) - 11
n(3) = n(3) - 2
showfang 0
situation = 6
End If
End If
Case 6
If (n(3) + 2) Mod 10 > 0 Then
If cmdfang(n(2) + 11).Visible = False And _
cmdfang(n(3) + 2).Visible = False Then
hidefang 0
n(0) = n(0) + 9
n(2) = n(2) + 11
n(3) = n(3) + 2
showfang 0
situation = 5
End If
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 7 '这是T型方块
If n(0) - 9 > 0 Then
If cmdfang(n(0) - 9).Visible = False Then
hidefang 0
n(0) = n(0) - 9
n(2) = n(2) + 9
n(3) = n(3) - 11
showfang 0
situation = 8
End If
End If
Case 8
If (n(0) + 11) Mod 10 > 0 Then
If cmdfang(n(0) + 11).Visible = False Then
hidefang 0
n(0) = n(0) + 11
n(2) = n(2) - 11
n(3) = n(3) - 9
showfang 0
situation = 9
End If
End If
Case 9
If n(0) + 9 < 199 Then
If cmdfang(n(0) + 9).Visible = False Then
hidefang 0
n(0) = n(0) + 9
n(2) = n(2) - 9
n(3) = n(3) + 11
showfang 0
situation = 10
End If
End If
Case 10
If (n(0) - 11) Mod 10 < 9 Then
If cmdfang(n(0) - 11).Visible = False Then
hidefang 0
n(0) = n(0) - 11
n(2) = n(2) + 11
n(3) = n(3) + 9
showfang 0
situation = 7
End If
End If
'm(3)记录预览区的四个活动方块的编号
Private situation, situation2, linenum, t As Integer 'situation记录游戏区的方块样式
'situation2记录预览区的方块样式
'linenum记录一次消除的行数
Private Sub hidefang(a As Integer) '定义使方块不可见的过程
Select Case a
Case 0 'a=0使游戏区方块不可见
cmdfang(n(0)).Visible = False
cmdfang(n(1)).Visible = False
cmdfang(n(2)).Visible = False
cmdfang(n(3)).Visible = False
Case 1 'a=1使预览区方块不可见
cmdfangnext(m(0)).Visible = False
cmdfangnext(m(1)).Visible = False
cmdfangnext(m(2)).Visible = False
cmdfangnext(m(3)).Visible = False
End Select
End Sub
Private Sub showfang(a As Integer) '定义使方块可见的过程
Select Case a
Case 0 'a=0使游戏区方块可见
cmdfang(n(0)).Visible = True
cmdfang(n(1)).Visible = True
cmdfang(n(2)).Visible = True
cmdfang(n(3)).Visible = True
Case 1 'a=1使预览区方块不可见
cmdfangnext(m(0)).Visible = True
cmdfangnext(m(1)).Visible = True
cmdfangnext(m(2)).Visible = True
cmdfangnext(m(3)).Visible = True
End Select
End Sub
Private Sub clearline() '定义消除整行的过程
For i = 190 To 10 Step -10
If cmdfang(i).Visible = True And _
cmdfang(i + 1).Visible = True And _
cmdfang(i + 2).Visible = True And _
cmdfang(i + 3).Visible = True And _
cmdfang(i + 4).Visible = True And _
cmdfang(i + 5).Visible = True And _
cmdfang(i + 6).Visible = True And _
cmdfang(i + 7).Visible = True And _
cmdfang(i + 8).Visible = True And _
cmdfang(i + 9).Visible = True Then
For j = i + 4 To i Step -1
t = 1
cmdfang(j).Visible = False
cmdfang(2 * i + 9 - j).Visible = False
For k = 1 To 4000
DoEvents
Next
t = 0
Next
linenum = linenum + 1
For j = i - 1 To 0 Step -1
If cmdfang(j).Visible = True Then
cmdfang(j).Visible = False
cmdfang(j + 10).Visible = True
End If
Next
clearline '为了实现连消数行,这里使用递归调用
End If
Next
End Sub
Private Function downable() As Boolean '自定义函数,确定方块是否能下降
If n(0) < 190 And n(1) < 190 And n(2) < 190 And n(3) < 190 Then
If cmdfang(n(0) + 10).Visible = False And _
cmdfang(n(1) + 10).Visible = False And _
cmdfang(n(2) + 10).Visible = False And _
cmdfang(n(3) + 10).Visible = False Then
downable = True
Else
downable = False
End If
Else
downable = False
End If
End Function
Private Function leftable() As Boolean '自定义函数,确定方块是否能左移
If n(0) Mod 10 <> 0 And n(1) Mod 10 <> 0 And n(2) Mod 10 <> 0 And n(3) Mod 10 <> 0 Then
If cmdfang(n(0) - 1).Visible = False And _
cmdfang(n(1) - 1).Visible = False And _
cmdfang(n(2) - 1).Visible = False And _
cmdfang(n(3) - 1).Visible = False Then
leftable = True
Else
leftable = False
End If
Else
leftable = False
End If
End Function
Private Function rightable() As Boolean '自定义函数,确定方块是否能右移
If n(0) Mod 10 <> 9 And n(1) Mod 10 <> 9 And n(2) Mod 10 <> 9 And n(3) Mod 10 <> 9 Then
If cmdfang(n(0) + 1).Visible = False And _
cmdfang(n(1) + 1).Visible = False And _
cmdfang(n(2) + 1).Visible = False And _
cmdfang(n(3) + 1).Visible = False Then
rightable = True
Else
rightable = False
End If
Else
rightable = False
End If
End Function
Private Sub loadfangkuai() '定义随机产生一种方块的过程
Select Case Int(Rnd * 6)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 0 '这是长条型方块
Select Case Int(Rnd * 2)
Case 0
m(0) = 3
m(1) = 4
m(2) = 5
m(3) = 6
situation2 = 0
Case 1
m(0) = 5
m(1) = 15
m(2) = 25
m(3) = 35
situation2 = 1
End Select
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 1 '这是正方形方块
m(0) = 4
m(1) = 5
m(2) = 14
m(3) = 15
situation2 = 2
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 2 '这是正S型方块
Select Case Int(Rnd * 2)
Case 0
m(0) = 6
m(1) = 5
m(2) = 15
m(3) = 14
situation2 = 3
Case 1
m(0) = 4
m(1) = 14
m(2) = 15
m(3) = 25
situation2 = 4
End Select
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 3 '这是反S型方块
Select Case Int(Rnd * 2)
Case 0
m(0) = 4
m(1) = 5
m(2) = 15
m(3) = 16
situation2 = 5
Case 1
m(0) = 5
m(1) = 15
m(2) = 14
m(3) = 24
situation2 = 6
End Select
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 4 '这是T型方块
Select Case Int(Rnd * 4)
Case 0
m(0) = 4
m(1) = 5
m(2) = 6
m(3) = 15
situation2 = 7
Case 1
m(0) = 5
m(1) = 15
m(2) = 25
m(3) = 14
situation2 = 8
Case 2
m(0) = 16
m(1) = 15
m(2) = 14
m(3) = 5
situation2 = 9
Case 3
m(0) = 24
m(1) = 14
m(2) = 4
m(3) = 15
situation2 = 10
End Select
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 5 '这是正7字型方块
Select Case Int(Rnd * 4)
Case 0
m(0) = 4
m(1) = 5
m(2) = 15
m(3) = 25
situation2 = 11
Case 1
m(0) = 5
m(1) = 15
m(2) = 14
m(3) = 13
situation2 = 12
Case 2
m(0) = 25
m(1) = 24
m(2) = 14
m(3) = 4
situation2 = 13
Case 3
m(0) = 14
m(1) = 4
m(2) = 5
m(3) = 6
situation2 = 14
End Select
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 6 '这是反7字型方块
Select Case Int(Rnd * 4)
Case 0
m(0) = 5
m(1) = 4
m(2) = 14
m(3) = 24
situation2 = 15
Case 1
m(0) = 15
m(1) = 5
m(2) = 4
m(3) = 3
situation2 = 16
Case 2
m(0) = 24
m(1) = 25
m(2) = 15
m(3) = 5
situation2 = 17
Case 3
m(0) = 4
m(1) = 14
m(2) = 15
m(3) = 16
situation2 = 18
End Select
End Select
End Sub
Private Sub zhuan() '定义使方块旋转的过程
Select Case situation
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 0 '这是长条型方块
If n(0) - 18 >= 2 And n(3) + 9 <= 198 Then
If cmdfang(n(0) - 18).Visible = False And _
cmdfang(n(1) - 9).Visible = False And _
cmdfang(n(3) + 9).Visible = False Then
hidefang 0
n(0) = n(0) - 18
n(1) = n(1) - 9
n(3) = n(3) + 9
showfang 0
situation = 1
End If
End If
Case 1
If (n(0) + 18) Mod 10 < 8 And (n(3) - 9) Mod 10 > 0 Then
If cmdfang(n(0) + 18).Visible = False And _
cmdfang(n(1) + 9).Visible = False And _
cmdfang(n(3) - 9).Visible = False Then
hidefang 0
n(0) = n(0) + 18
n(1) = n(1) + 9
n(3) = n(3) - 9
showfang 0
situation = 0
End If
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 2 '这是正方形方块
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 3 '这是正S型方块
If n(0) - 11 > 1 Then
If cmdfang(n(0) - 11).Visible = False And _
cmdfang(n(3) + 2).Visible = False Then
hidefang 0
n(0) = n(0) - 11
n(2) = n(2) - 9
n(3) = n(3) + 2
showfang 0
situation = 4
End If
End If
Case 4
If (n(3) - 2) Mod 10 < 9 Then
If cmdfang(n(2) + 9).Visible = False And _
cmdfang(n(3) - 2).Visible = False Then
hidefang 0
n(0) = n(0) + 11
n(2) = n(2) + 9
n(3) = n(3) - 2
showfang 0
situation = 3
End If
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 5 '这是反S型方块
If n(0) - 9 > 1 Then
If cmdfang(n(0) - 9).Visible = False And _
cmdfang(n(3) - 2).Visible = False Then
hidefang 0
n(0) = n(0) - 9
n(2) = n(2) - 11
n(3) = n(3) - 2
showfang 0
situation = 6
End If
End If
Case 6
If (n(3) + 2) Mod 10 > 0 Then
If cmdfang(n(2) + 11).Visible = False And _
cmdfang(n(3) + 2).Visible = False Then
hidefang 0
n(0) = n(0) + 9
n(2) = n(2) + 11
n(3) = n(3) + 2
showfang 0
situation = 5
End If
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 7 '这是T型方块
If n(0) - 9 > 0 Then
If cmdfang(n(0) - 9).Visible = False Then
hidefang 0
n(0) = n(0) - 9
n(2) = n(2) + 9
n(3) = n(3) - 11
showfang 0
situation = 8
End If
End If
Case 8
If (n(0) + 11) Mod 10 > 0 Then
If cmdfang(n(0) + 11).Visible = False Then
hidefang 0
n(0) = n(0) + 11
n(2) = n(2) - 11
n(3) = n(3) - 9
showfang 0
situation = 9
End If
End If
Case 9
If n(0) + 9 < 199 Then
If cmdfang(n(0) + 9).Visible = False Then
hidefang 0
n(0) = n(0) + 9
n(2) = n(2) - 9
n(3) = n(3) + 11
showfang 0
situation = 10
End If
End If
Case 10
If (n(0) - 11) Mod 10 < 9 Then
If cmdfang(n(0) - 11).Visible = False Then
hidefang 0
n(0) = n(0) - 11
n(2) = n(2) + 11
n(3) = n(3) + 9
showfang 0
situation = 7
End If
End If
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询