急求连连看简单vb程序
难度以时间长短来分简单中等较难,只要普通能连即可,不要求消图后移动.无需音效、排行榜。。。高手来帮下忙。。。急求。。。谢谢。。。...
难度以时间长短来分简单中等较难,只要普通能连即可,不要求消图后移动.无需音效、排行榜。。。高手来帮下忙。。。急求。。。谢谢。。。
展开
展开全部
给你段代码吧,直接复制粘贴到文本文件,改名为1.frm即可运行(关于连线的判断自己需要加一段算法代码,本程序中没写):
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Form1"
ClientHeight = 7680
ClientLeft = 45
ClientTop = 435
ClientWidth = 7170
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 7680
ScaleWidth = 7170
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Left = 6720
Top = 2880
End
Begin VB.ComboBox dengji
Height = 300
Left = 4680
Style = 2 'Dropdown List
TabIndex = 6
Top = 720
Width = 1935
End
Begin VB.CommandButton Jieshu
Caption = "结束游戏"
Height = 495
Left = 1800
TabIndex = 5
Top = 600
Width = 1215
End
Begin VB.PictureBox P1
Appearance = 0 'Flat
BackColor = &H00000000&
ForeColor = &H80000008&
Height = 255
Left = 240
ScaleHeight = 225
ScaleWidth = 6585
TabIndex = 4
Top = 240
Width = 6615
End
Begin VB.PictureBox p0
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 255
Left = 240
ScaleHeight = 225
ScaleWidth = 6585
TabIndex = 3
Top = 240
Width = 6615
End
Begin VB.Frame Frame1
Height = 6255
Left = 360
TabIndex = 1
Top = 1200
Width = 6255
Begin VB.PictureBox nPic
BackColor = &H008080FF&
BorderStyle = 0 'None
Height = 615
Index = 0
Left = 360
ScaleHeight = 615
ScaleWidth = 105
TabIndex = 2
Top = 240
Visible = 0 'False
Width = 100
End
End
Begin VB.CommandButton kaishi
Caption = "开始游戏"
Height = 495
Left = 240
TabIndex = 0
Top = 600
Width = 1335
End
Begin VB.Label Label1
Caption = "难度等级"
Height = 255
Left = 3720
TabIndex = 7
Top = 720
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim tmp() As Integer '假设有10种类别的图片,本数组用以记录每组图片加载的次数
Dim pic(10) As ColorConstants
Dim tCnt As Integer
Dim Fhit As ColorConstants
Dim FhitIndex As Long
Private Sub Command1_Click()
End Sub
Private Sub jieshu_Click()
Timer1.Enabled = False
dengji.Enabled = True
P1.Width = p0.Width
Jieshu.Enabled = False
kaishi.Enabled = True
End Sub
Private Sub Form_Initialize()
Dim i As Integer
For i = 1 To 10
pic(i) = RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255))
Next i
dengji.Clear
For i = 3 To 1 Step -1
dengji.AddItem i & "分钟"
Next i
dengji.ListIndex = 0
Timer1.Interval = 1000
Timer1.Enabled = False
Jieshu.Enabled = False
End Sub
Private Sub Form_Load()
'IntPic
End Sub
'初始化控件数组
Private Sub IntPic()
Dim i As Integer
ReDim tmp(10) As Integer
nPic(0).Move 200, 200, 500, 500
nPic(0).Visible = False
For i = 1 To 100
If ExistPic(nPic(i)) Then Unload nPic(i)
Load nPic(i)
nPic(i).Visible = True
nPic(i).Width = 500
nPic(i).BackColor = pic(LoadPic)
nPic(i).Top = (i Mod 10) * (500 + 100) + 200
nPic(i).Left = ((i - 1) \ 10) * (500 + 100) + 200
nPic(i).Visible = True
Next i
End Sub
'判断控件是否存在
Function ExistPic(obj As PictureBox) As Boolean
On Error GoTo errobj
obj.Move obj.Left
ExistPic = True
Exit Function
errobj:
ExistPic = False
End Function
'随机赋予控件颜色,可更改为指定的图片
Private Function LoadPic()
Dim ntmp As Integer
Do
ntmp = Int(Rnd * 10) + 1
If tmp(ntmp) < 10 Then
LoadPic = ntmp
tmp(ntmp) = tmp(ntmp) + 1
Exit Do
End If
Loop
End Function
Private Sub kaishi_Click()
tCnt = 0
IntPic
Timer1.Enabled = True
dengji.Enabled = False
kaishi.Enabled = False
Jieshu.Enabled = True
End Sub
Private Sub nPic_Click(Index As Integer)
If Fhit = 0 Then
Fhit = nPic(Index).BackColor
FhitIndex = Index
nPic(Index).BorderStyle = 1
ElseIf Fhit = nPic(Index).BackColor And Index <> FhitIndex Then
nPic(FhitIndex).Visible = False
nPic(Index).Visible = False
FhitIndex = 0
Fhit = 0
nPic(Index).BorderStyle = 1
nPic(FhitIndex).BorderStyle = 0
Else
Fhit = nPic(Index).BackColor
nPic(FhitIndex).BorderStyle = 0
nPic(Index).BorderStyle = 1
FhitIndex = Index
End If
Debug.Print Fhit
End Sub
Private Sub Timer1_Timer()
If tCnt > Val(dengji.Text) * 60 Then
MsgBox "游戏结束"
Timer1.Enabled = False
Exit Sub
End If
tCnt = tCnt + 1
P1.Width = p0.Width * (1 - Format((tCnt / (Val(dengji.Text) * 60)), "0.000"))
End Sub
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Form1"
ClientHeight = 7680
ClientLeft = 45
ClientTop = 435
ClientWidth = 7170
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 7680
ScaleWidth = 7170
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Left = 6720
Top = 2880
End
Begin VB.ComboBox dengji
Height = 300
Left = 4680
Style = 2 'Dropdown List
TabIndex = 6
Top = 720
Width = 1935
End
Begin VB.CommandButton Jieshu
Caption = "结束游戏"
Height = 495
Left = 1800
TabIndex = 5
Top = 600
Width = 1215
End
Begin VB.PictureBox P1
Appearance = 0 'Flat
BackColor = &H00000000&
ForeColor = &H80000008&
Height = 255
Left = 240
ScaleHeight = 225
ScaleWidth = 6585
TabIndex = 4
Top = 240
Width = 6615
End
Begin VB.PictureBox p0
Appearance = 0 'Flat
BackColor = &H80000005&
ForeColor = &H80000008&
Height = 255
Left = 240
ScaleHeight = 225
ScaleWidth = 6585
TabIndex = 3
Top = 240
Width = 6615
End
Begin VB.Frame Frame1
Height = 6255
Left = 360
TabIndex = 1
Top = 1200
Width = 6255
Begin VB.PictureBox nPic
BackColor = &H008080FF&
BorderStyle = 0 'None
Height = 615
Index = 0
Left = 360
ScaleHeight = 615
ScaleWidth = 105
TabIndex = 2
Top = 240
Visible = 0 'False
Width = 100
End
End
Begin VB.CommandButton kaishi
Caption = "开始游戏"
Height = 495
Left = 240
TabIndex = 0
Top = 600
Width = 1335
End
Begin VB.Label Label1
Caption = "难度等级"
Height = 255
Left = 3720
TabIndex = 7
Top = 720
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim tmp() As Integer '假设有10种类别的图片,本数组用以记录每组图片加载的次数
Dim pic(10) As ColorConstants
Dim tCnt As Integer
Dim Fhit As ColorConstants
Dim FhitIndex As Long
Private Sub Command1_Click()
End Sub
Private Sub jieshu_Click()
Timer1.Enabled = False
dengji.Enabled = True
P1.Width = p0.Width
Jieshu.Enabled = False
kaishi.Enabled = True
End Sub
Private Sub Form_Initialize()
Dim i As Integer
For i = 1 To 10
pic(i) = RGB(Int(Rnd * 255), Int(Rnd * 255), Int(Rnd * 255))
Next i
dengji.Clear
For i = 3 To 1 Step -1
dengji.AddItem i & "分钟"
Next i
dengji.ListIndex = 0
Timer1.Interval = 1000
Timer1.Enabled = False
Jieshu.Enabled = False
End Sub
Private Sub Form_Load()
'IntPic
End Sub
'初始化控件数组
Private Sub IntPic()
Dim i As Integer
ReDim tmp(10) As Integer
nPic(0).Move 200, 200, 500, 500
nPic(0).Visible = False
For i = 1 To 100
If ExistPic(nPic(i)) Then Unload nPic(i)
Load nPic(i)
nPic(i).Visible = True
nPic(i).Width = 500
nPic(i).BackColor = pic(LoadPic)
nPic(i).Top = (i Mod 10) * (500 + 100) + 200
nPic(i).Left = ((i - 1) \ 10) * (500 + 100) + 200
nPic(i).Visible = True
Next i
End Sub
'判断控件是否存在
Function ExistPic(obj As PictureBox) As Boolean
On Error GoTo errobj
obj.Move obj.Left
ExistPic = True
Exit Function
errobj:
ExistPic = False
End Function
'随机赋予控件颜色,可更改为指定的图片
Private Function LoadPic()
Dim ntmp As Integer
Do
ntmp = Int(Rnd * 10) + 1
If tmp(ntmp) < 10 Then
LoadPic = ntmp
tmp(ntmp) = tmp(ntmp) + 1
Exit Do
End If
Loop
End Function
Private Sub kaishi_Click()
tCnt = 0
IntPic
Timer1.Enabled = True
dengji.Enabled = False
kaishi.Enabled = False
Jieshu.Enabled = True
End Sub
Private Sub nPic_Click(Index As Integer)
If Fhit = 0 Then
Fhit = nPic(Index).BackColor
FhitIndex = Index
nPic(Index).BorderStyle = 1
ElseIf Fhit = nPic(Index).BackColor And Index <> FhitIndex Then
nPic(FhitIndex).Visible = False
nPic(Index).Visible = False
FhitIndex = 0
Fhit = 0
nPic(Index).BorderStyle = 1
nPic(FhitIndex).BorderStyle = 0
Else
Fhit = nPic(Index).BackColor
nPic(FhitIndex).BorderStyle = 0
nPic(Index).BorderStyle = 1
FhitIndex = Index
End If
Debug.Print Fhit
End Sub
Private Sub Timer1_Timer()
If tCnt > Val(dengji.Text) * 60 Then
MsgBox "游戏结束"
Timer1.Enabled = False
Exit Sub
End If
tCnt = tCnt + 1
P1.Width = p0.Width * (1 - Format((tCnt / (Val(dengji.Text) * 60)), "0.000"))
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询