frmmain.frm
资源名称:VBdesign.zip [点击查看]
上传用户:wuyi06
上传日期:2015-04-09
资源大小:1872k
文件大小:37k
源码类别:
压缩解压
开发平台:
Visual Basic
- VERSION 5.00
- Begin VB.Form frmmain
- BackColor = &H00000000&
- BorderStyle = 1 'Fixed Single
- Caption = "俄罗斯方块"
- ClientHeight = 6390
- ClientLeft = 3195
- ClientTop = 1140
- ClientWidth = 5205
- Icon = "frmmain.frx":0000
- KeyPreview = -1 'True
- LinkTopic = "Form1"
- MaxButton = 0 'False
- Picture = "frmmain.frx":08CA
- ScaleHeight = 6390
- ScaleWidth = 5205
- Begin VB.Timer Timer4
- Interval = 100
- Left = 1800
- Top = 5880
- End
- Begin VB.Timer tmrmain
- Enabled = 0 'False
- Interval = 1000
- Left = 840
- Top = 5880
- End
- Begin VB.Timer Timer2
- Interval = 300
- Left = 1320
- Top = 5880
- End
- Begin VB.Timer Timer1
- Left = 360
- Top = 5880
- End
- Begin VB.Frame fraoption
- BackColor = &H00000000&
- Caption = "游戏设置:"
- ForeColor = &H000000FF&
- Height = 1335
- Left = 3480
- TabIndex = 4
- Top = 1680
- Width = 1335
- Begin VB.TextBox txtscore
- Alignment = 1 'Right Justify
- Enabled = 0 'False
- ForeColor = &H00C00000&
- Height = 270
- Left = 600
- TabIndex = 10
- Text = "0"
- Top = 960
- Width = 615
- End
- Begin VB.TextBox txthard
- Alignment = 2 'Center
- Enabled = 0 'False
- ForeColor = &H00FF0000&
- Height = 270
- Left = 780
- TabIndex = 9
- Text = "0"
- Top = 240
- Width = 435
- End
- Begin VB.TextBox txtlevel
- Alignment = 2 'Center
- Enabled = 0 'False
- ForeColor = &H00FF0000&
- Height = 270
- Left = 480
- TabIndex = 5
- Text = "1"
- Top = 600
- Width = 380
- End
- Begin VB.Label Label1
- BackColor = &H00000000&
- Caption = "得分"
- BeginProperty Font
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H0000FFFF&
- Height = 255
- Left = 120
- TabIndex = 11
- Top = 1005
- Width = 495
- End
- Begin VB.Label lblhard
- BackColor = &H00000000&
- Caption = "难度"
- BeginProperty Font
- Name = "宋体"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H0000FFFF&
- Height = 255
- Left = 120
- TabIndex = 8
- Top = 240
- Width = 615
- End
- Begin VB.Label lbldi
- Alignment = 2 'Center
- BackColor = &H00000000&
- Caption = "第"
- BeginProperty Font
- Name = "宋体"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H0000FFFF&
- Height = 255
- Left = 120
- TabIndex = 7
- Top = 600
- Width = 255
- End
- Begin VB.Label lblguan
- Alignment = 2 'Center
- BackColor = &H00000000&
- Caption = "关"
- BeginProperty Font
- Name = "宋体"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H0000FFFF&
- Height = 255
- Left = 960
- TabIndex = 6
- Top = 600
- Width = 255
- End
- End
- Begin VB.PictureBox picnext
- BackColor = &H00000000&
- BorderStyle = 0 'None
- Enabled = 0 'False
- Height = 1140
- Left = 3480
- ScaleHeight = 3.8
- ScaleMode = 0 'User
- ScaleWidth = 3.8
- TabIndex = 2
- Top = 360
- Width = 1140
- Begin VB.CommandButton cmdfangnext
- Height = 300
- Index = 0
- Left = 0
- Picture = "frmmain.frx":43E5C
- Style = 1 'Graphical
- TabIndex = 3
- Top = 0
- Width = 300
- End
- End
- Begin VB.PictureBox picmain
- Height = 6060
- Left = 240
- Picture = "frmmain.frx":47103
- ScaleHeight = 20
- ScaleMode = 0 'User
- ScaleWidth = 10
- TabIndex = 0
- Top = 120
- Width = 3060
- Begin VB.CommandButton cmdfang
- Height = 300
- Index = 0
- Left = 0
- Picture = "frmmain.frx":4F81C
- Style = 1 'Graphical
- TabIndex = 1
- Top = 0
- Width = 300
- End
- End
- Begin VB.Label Label2
- BackColor = &H00000000&
- Caption = " 游戏忠告: 适度游戏益脑, 沉迷游戏伤身, 合理安排时间, 享受健康生活."
- DragIcon = "frmmain.frx":52AE7
- BeginProperty Font
- Name = "华文中宋"
- Size = 10.5
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00FFFF00&
- Height = 1455
- Left = 3360
- TabIndex = 12
- Top = 3960
- Width = 1575
- End
- Begin VB.Image snow
- Height = 375
- Index = 0
- Left = 4560
- Top = 5400
- Width = 375
- End
- Begin VB.Menu files
- Caption = "文件(&F)"
- Begin VB.Menu start
- Caption = "开始"
- Shortcut = {F1}
- End
- Begin VB.Menu go
- Caption = "继续"
- Enabled = 0 'False
- Shortcut = {F2}
- End
- Begin VB.Menu stop1
- Caption = "暂停"
- Enabled = 0 'False
- Shortcut = {F3}
- End
- Begin VB.Menu heng
- Caption = "-"
- End
- Begin VB.Menu exit
- Caption = "退出"
- Shortcut = ^Q
- End
- End
- Begin VB.Menu set
- Caption = "设置(&S)"
- Begin VB.Menu grade
- Caption = "游戏级别(高度)"
- Begin VB.Menu gao
- Caption = "一"
- Index = 0
- End
- Begin VB.Menu gao
- Caption = "二"
- Index = 1
- End
- Begin VB.Menu gao
- Caption = "三"
- Index = 2
- End
- Begin VB.Menu gao
- Caption = "四"
- Index = 3
- End
- Begin VB.Menu gao
- Caption = "五"
- Index = 4
- End
- Begin VB.Menu gao
- Caption = "六"
- Index = 5
- End
- Begin VB.Menu gao
- Caption = "七"
- Index = 6
- End
- Begin VB.Menu gao
- Caption = "八"
- Index = 7
- End
- Begin VB.Menu gao
- Caption = "九"
- Index = 8
- End
- Begin VB.Menu gao
- Caption = "十"
- Index = 9
- End
- End
- Begin VB.Menu speed
- Caption = "游戏速度"
- Begin VB.Menu fast
- Caption = "一"
- Index = 0
- End
- Begin VB.Menu fast
- Caption = "二"
- Index = 1
- End
- Begin VB.Menu fast
- Caption = "三"
- Index = 2
- End
- Begin VB.Menu fast
- Caption = "四"
- Index = 3
- End
- Begin VB.Menu fast
- Caption = "五"
- Index = 4
- End
- Begin VB.Menu fast
- Caption = "六"
- Index = 5
- End
- Begin VB.Menu fast
- Caption = "七"
- Index = 6
- End
- Begin VB.Menu fast
- Caption = "八"
- Index = 7
- End
- Begin VB.Menu fast
- Caption = "九"
- Index = 8
- End
- Begin VB.Menu fast
- Caption = "十"
- Index = 9
- End
- End
- End
- Begin VB.Menu kaoyan
- Caption = "考验(&K)"
- Begin VB.Menu yincang
- Caption = "隐藏"
- Shortcut = {F5}
- End
- Begin VB.Menu xianshi
- Caption = "显示"
- Shortcut = {F6}
- End
- End
- Begin VB.Menu help
- Caption = "帮助(&H)..."
- Begin VB.Menu about
- Caption = "操作提示"
- Shortcut = {F7}
- End
- End
- End
- Attribute VB_Name = "frmmain"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
- Dim IsMusicOn As Boolean
- Dim RetValue As Long
- Private n(3), m(3) As Integer 'n(3)记录游戏区的四个活动方块的编号
- 'm(3)记录预览区的四个活动方块的编号
- Private situation, situation2, linenum, t As Integer 'situation记录游戏区的方块样式
- 'situation2记录预览区的方块样式
- 'linenum记录一次消除的行数
- Dim no As Integer
- Dim num As Integer
- Dim dx(), dy(), xp(), yp(), am(), stx(), sty() As Double
- 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
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- 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 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