frmmain.frm
资源名称:七八个vb游戏.rar [点击查看]
上传用户:tashmp
上传日期:2010-04-03
资源大小:882k
文件大小:31k
源码类别:
其他游戏
开发平台:
Visual Basic
- VERSION 5.00
- Begin VB.Form frmmain
- BorderStyle = 1 'Fixed Single
- Caption = "俄罗斯方块"
- ClientHeight = 6570
- ClientLeft = 10110
- ClientTop = 330
- ClientWidth = 5775
- Icon = "frmmain.frx":0000
- KeyPreview = -1 'True
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 6570
- ScaleWidth = 5775
- StartUpPosition = 2 '屏幕中心
- Begin VB.Frame frascore
- Caption = "分数:"
- Height = 615
- Left = 3600
- TabIndex = 14
- Top = 3240
- Width = 1335
- Begin VB.TextBox txtscore
- Alignment = 1 'Right Justify
- Enabled = 0 'False
- Height = 270
- Left = 120
- TabIndex = 15
- Text = "0"
- Top = 240
- Width = 1095
- End
- End
- Begin VB.Frame fraoption
- Caption = "游戏设置:"
- Height = 1455
- Left = 3600
- TabIndex = 7
- Top = 1680
- Width = 1335
- Begin VB.TextBox txthard
- Alignment = 2 'Center
- Enabled = 0 'False
- Height = 270
- Left = 780
- TabIndex = 13
- Text = "0"
- Top = 240
- Width = 375
- End
- Begin VB.TextBox txtlevel
- Alignment = 2 'Center
- Enabled = 0 'False
- Height = 270
- Left = 480
- TabIndex = 9
- Text = "1"
- Top = 600
- Width = 380
- End
- Begin VB.CommandButton cmdoption
- Caption = "游戏选项"
- Height = 375
- Left = 120
- TabIndex = 8
- Top = 960
- Width = 1095
- End
- Begin VB.Label lblhard
- Caption = "难度"
- BeginProperty Font
- Name = "宋体"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 240
- TabIndex = 12
- Top = 240
- Width = 615
- End
- Begin VB.Label lbldi
- Alignment = 2 'Center
- Caption = "第"
- BeginProperty Font
- Name = "宋体"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 240
- TabIndex = 11
- Top = 600
- Width = 255
- End
- Begin VB.Label lblguan
- Alignment = 2 'Center
- Caption = "关"
- BeginProperty Font
- Name = "宋体"
- Size = 12
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Left = 900
- TabIndex = 10
- Top = 600
- Width = 255
- End
- End
- Begin VB.CommandButton cmdabout
- Caption = "关于游戏"
- Height = 375
- Left = 3600
- TabIndex = 6
- Top = 3960
- Width = 1335
- End
- Begin VB.CommandButton cmdpause
- Caption = "暂停"
- Enabled = 0 'False
- Height = 375
- Left = 3600
- TabIndex = 5
- Top = 5400
- Width = 1335
- End
- Begin VB.CommandButton cmdstart
- Caption = "开始"
- Height = 375
- Left = 3600
- TabIndex = 0
- Top = 5880
- Width = 1335
- End
- Begin VB.PictureBox picnext
- Enabled = 0 'False
- Height = 1260
- Left = 3600
- ScaleHeight = 4
- ScaleMode = 0 'User
- ScaleWidth = 4
- TabIndex = 3
- Top = 240
- Width = 1260
- Begin VB.CommandButton cmdfangnext
- Height = 300
- Index = 0
- Left = 0
- TabIndex = 4
- Top = 0
- Width = 300
- End
- End
- Begin VB.PictureBox picmain
- Height = 6060
- Left = 240
- Picture = "frmmain.frx":08CA
- ScaleHeight = 20
- ScaleMode = 0 'User
- ScaleWidth = 10
- TabIndex = 1
- Top = 240
- Width = 3060
- Begin VB.CommandButton cmdfang
- Height = 300
- Index = 0
- Left = 0
- TabIndex = 2
- Top = 0
- Width = 300
- End
- End
- Begin VB.Timer tmrmain
- Enabled = 0 'False
- Interval = 1000
- Left = 5160
- Top = 5040
- End
- Begin VB.Image Image1
- Height = 1005
- Left = 3750
- Picture = "frmmain.frx":E8B5
- Top = 4380
- Width = 1020
- End
- End
- Attribute VB_Name = "frmmain"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- 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
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- 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 cmdoption_Click()
- frmoption.Show
- End Sub
- Private Sub cmdpause_Click() '编写暂定按钮的代码
- Select Case cmdpause.Caption
- Case "暂停"
- cmdpause.Caption = "继续"
- tmrmain.Enabled = False
- cmdabout.Enabled = True
- Case "继续"
- cmdpause.Caption = "暂停"
- tmrmain.Enabled = True
- cmdabout.Enabled = False
- picmain.SetFocus
- End Select
- End Sub
- Private Sub cmdstart_Click()
- If cmdstart.Caption = "开始" Then
- 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 '设置一些控件的可用性
- cmdpause.Enabled = True
- cmdoption.Enabled = False
- cmdabout.Enabled = False
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- hidefang 1 '清空预览区
- loadfangkuai '继续在预览区产生方块
- showfang 1
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- cmdstart.Caption = "结束"
- Else
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- tmrmain.Enabled = False '设置一些控件的可用性
- cmdpause.Enabled = False
- cmdoption.Enabled = True
- cmdabout.Enabled = True
- ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- For i = 1 To 199
- cmdfang(i).Visible = False
- Next
- cmdstart.Caption = "开始"
- txtscore.Text = "0"
- linenum = 0
- 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 vbKeyReturn '点击旋转键(回车键)
- 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 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 cmdstart_Click: Exit Sub
- '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
- 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