?? frmmain.frm
字號:
End If
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 11 '這是正7字型方塊
If n(0) - 9 > 1 And (n(3) - 22) Mod 10 < 9 Then
If cmdfang(n(0) - 9).Visible = False And _
cmdfang(n(3) - 22).Visible = False Then
hidefang 0
n(0) = n(0) - 9
n(2) = n(2) - 11
n(3) = n(3) - 22
showfang 0
situation = 12
End If
End If
Case 12
If (n(0) + 11) Mod 10 > 0 And n(3) - 18 > 1 Then
If cmdfang(n(0) + 11).Visible = False And _
cmdfang(n(3) - 18).Visible = False Then
hidefang 0
n(0) = n(0) + 11
n(2) = n(2) - 9
n(3) = n(3) - 18
showfang 0
situation = 13
End If
End If
Case 13
If n(0) + 9 < 198 And (n(3) + 22) Mod 10 > 0 Then
If cmdfang(n(0) + 9).Visible = False And _
cmdfang(n(3) + 22).Visible = False Then
hidefang 0
n(0) = n(0) + 9
n(2) = n(2) + 11
n(3) = n(3) + 22
showfang 0
situation = 14
End If
End If
Case 14
If (n(0) - 11) Mod 10 < 9 And n(3) + 18 < 198 Then
If cmdfang(n(0) - 11).Visible = False And _
cmdfang(n(3) + 18).Visible = False Then
hidefang 0
n(0) = n(0) - 11
n(2) = n(2) + 9
n(3) = n(3) + 18
showfang 0
situation = 11
End If
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case 15 '這是反7字型方塊
If (n(3) - 22) Mod 10 < 8 Then
If cmdfang(n(2) - 11).Visible = False And _
cmdfang(n(3) - 22).Visible = False Then
hidefang 0
n(0) = n(0) + 9
n(2) = n(2) - 11
n(3) = n(3) - 22
showfang 0
situation = 16
End If
End If
Case 16
If n(3) - 18 > 1 Then
If cmdfang(n(2) - 9).Visible = False And _
cmdfang(n(3) - 18).Visible = False Then
hidefang 0
n(0) = n(0) - 11
n(2) = n(2) - 9
n(3) = n(3) - 18
showfang 0
situation = 17
End If
End If
Case 17
If (n(3) + 22) Mod 10 > 1 Then
If cmdfang(n(2) + 11).Visible = False And _
cmdfang(n(3) + 22).Visible = False Then
hidefang 0
n(0) = n(0) - 9
n(2) = n(2) + 11
n(3) = n(3) + 22
showfang 0
situation = 18
End If
End If
Case 18
If n(3) + 18 < 198 Then
If cmdfang(n(2) + 9).Visible = False And _
cmdfang(n(3) + 18).Visible = False Then
hidefang 0
n(0) = n(0) + 11
n(2) = n(2) + 9
n(3) = n(3) + 18
showfang 0
situation = 15
End If
End If
End Select
End Sub
Private Sub about_Click()
Dim Msg As String
Msg = "鍵盤控制方法:" & vbCrLf
Msg = Msg & "1.左右光標鍵控制方塊左右移動。" & vbCrLf
Msg = Msg & "2.上光標鍵控制方塊順時針旋轉90度。" & vbCrLf
Msg = Msg & "3.下光標鍵控制方塊加速向下移動。" & vbCrLf & vbCrLf
Msg = Msg & "程序設計者: 王志偉 李虎" & vbCrLf
Msg = Msg & " 版權所有,請勿盜版 " & vbCrLf
Msg = Msg & " E-Mail: lihu_2008@163.com"
MsgBox Msg, vbOKOnly + vbQuestion, Me.Caption
End Sub
Private Sub fast_Click(Index As Integer)
Dim k As Integer
For k = 0 To 9
fast(k).Checked = False
Next k
fast(Index).Checked = True
txtlevel.Text = Index + 1
End Sub
Private Sub gao_Click(Index As Integer)
Dim l As Integer
For l = 0 To 9
gao(l).Checked = False
Next l
gao(Index).Checked = True
txthard.Text = Index + 1
End Sub
Private Sub picmain_Click()
End Sub
Private Sub start_Click()
picmain.SetFocus
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
tmrmain.Interval = 1000 / Val(txtlevel.Text) '根據關卡系數設置方塊下降速度
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For i = 19 To 20 - Val(txthard.Text) Step -1 '根據難度系數產生不同難度的地基
For j = i * 10 To i * 10 + 9
If Rnd >= 0.5 Then cmdfang(j).Visible = True
Next
Next
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For i = 0 To 3 '引用預覽區已經產生的方塊
n(i) = m(i)
Next
showfang 0
situation = situation2
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
tmrmain.Enabled = True '設置一些控件的可用性
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
hidefang 1 '清空預覽區
loadfangkuai '繼續在預覽區產生方塊
showfang 1
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
stop1.Enabled = True
End Sub
Private Sub exit_Click()
StrMsg = "您是否繼續玩游戲?"
Ref = MsgBox(StrMsg, vbYesNo + vbQuestion, "游戲結束")
If Ref = vbYes Then
tmrmain.Enabled = True
Else
tmrmain.Enabled = False
Unload Me
End If
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If t = 0 Then
hidefang 0
Select Case KeyCode
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case vbKeyLeft '點擊向左鍵
If leftable() = True Then
For j = 0 To 3
cmdfang(n(j) - 1).Visible = True
n(j) = n(j) - 1
Next j
End If
showfang 0
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case vbKeyDown '點擊向下鍵
If downable() = True Then
For j = 0 To 3
cmdfang(n(j) + 10).Visible = True
n(j) = n(j) + 10
Next j
End If
showfang 0
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case vbKeyRight '點擊向右鍵
If rightable() = True Then
For j = 0 To 3
cmdfang(n(j) + 1).Visible = True
n(j) = n(j) + 1
Next j
End If
showfang 0
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case vbKeyUp '點擊旋轉鍵(向上鍵)
showfang 0
zhuan
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Case Else
showfang 0
End Select
End If
End Sub
Private Sub Form_Load()
Randomize '非正序的隨機數
For i = 1 To 199 '創建游戲區的方塊
Load cmdfang(i)
Next i
For i = 0 To 199 '在游戲區以10×20排列方塊
cmdfang(i).Left = (i Mod 10)
cmdfang(i).Top = i \ 10
cmdfang(i).Visible = False
Next i
For i = 1 To 39 '創建預覽區的方塊
Load cmdfangnext(i)
Next i
For i = 0 To 39 '在預覽區排列方塊
cmdfangnext(i).Left = (i Mod 10) - 3
cmdfangnext(i).Top = i \ 10
cmdfangnext(i).Visible = False
Next i
loadfangkuai '在預覽區產生第一個方塊
showfang 1
End Sub
Private Sub Form_Unload(Cancel As Integer)
IsMusicOn = False
RetValue = mciSendString("CLOSE BackgroundMusic", "", 0, 0)
End Sub
Private Sub stop1_Click()
tmrmain.Enabled = False
go.Enabled = True
stop1.Enabled = False
End Sub
Private Sub go_Click()
tmrmain.Enabled = True
go.Enabled = False
stop1.Enabled = True
End Sub
Private Sub Timer4_Timer()
Label2.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
End Sub
Private Sub tmrmain_Timer() '使方塊下降的Timer
hidefang 0
If downable() = True Then '能夠下降
For j = 0 To 3
n(j) = n(j) + 10
Next j
showfang 0
Else '不能繼續下降了
showfang 0
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
clearline '引用自定義方法,判斷是否消除滿行
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For i = 0 To 9 '如果方塊疊至最上層,游戲結束
If cmdfang(i).Visible = True Then Exit For
Next
If i < 10 Then
StrMsg = "輸了請不要灰心" & vbCrLf & "是否重新開始玩游戲?"
Ref = MsgBox(StrMsg, vbYesNo + vbQuestion, "俄羅斯方塊游戲")
If Ref = vbYes Then
For i = 1 To 199
cmdfang(i).Visible = False
Next i
txtscore.Text = "0"
linenum = 0
For i = 19 To 20 - Val(txthard.Text) Step -1 '根據難度系數產生不同難度的地基
For j = i * 10 To i * 10 + 9
If Rnd >= 0.5 Then cmdfang(j).Visible = True
Next
Next
Else
IsMusicOn = False
RetValue = mciSendString("CLOSE BackgroundMusic", "", 0, 0)
End
End If
End If
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
For i = 0 To 3 '引用預覽區已經產生的方塊
n(i) = m(i)
Next
showfang 0
situation = situation2
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
txtscore.Text = Str(Val(txtscore.Text) + 100 * (2 ^ linenum - 1)) '這段代碼控制加分
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'這段代碼控制過關升級
If Val(Right(txtscore.Text, 4)) < Val(Right(Str(Val(txtscore.Text) - 100 * (2 ^ linenum - 1)), 4)) Then
txtlevel.Text = Str(Val(txtlevel.Text) + 1)
tmrmain.Interval = 1000 / Val(txtlevel.Text)
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
linenum = 0
hidefang 1 '清空預覽區
loadfangkuai '繼續在預覽區產生方塊
showfang 1
End If
End Sub
Private Sub Timer1_Timer()
For i = 0 To num
yp(i) = yp(i) + sty(i)
If yp(i) > ScaleHeight - 50 Then
xp(i) = Rnd * (ScaleWidth - am(i) - 30)
yp(i) = 0
stx(i) = 0.02 + Rnd / 10
sty(i) = 0.7 + Rnd
End If
dx(i) = dx(i) + stx(i)
snow(i).Left = xp(i) + am(i) * Sin(dx(i))
snow(i).Top = yp(i)
Next i
End Sub
Private Sub yincang_Click()
picnext.Visible = False
yincang.Enabled = False
xianshi.Enabled = True
End Sub
Private Sub xianshi_Click()
picnext.Visible = True
yincang.Enabled = True
xianshi.Enabled = False
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -