主题:俺自编的一个VB游戏(别笑话我啊)
俺不习惯打包,所以把文件全贴上来了,大家麻烦一点把文件做好就行了。:-)
文件内容:
数字魔方.vbp
Type=Exe
Form=Form1.frm
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\WINDOWS\SYSTEM\StdOle2.tlb#OLE Automation
IconForm="Form1"
Startup="Form1"
HelpFile=""
Title="数字魔方"
ExeName32="数字魔方.exe"
Path32="..\..\..\WINDOWS\Desktop"
Command32=""
Name="数字魔方"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=4
AutoIncrementVer=1
ServerSupportFiles=0
VersionCompanyName="PC"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
数字魔方.vbw
Form1 = 53, 100, 423, 447, Z, 64, 25, 434, 372, C
Form1.frm
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "数字魔方"
ClientHeight = 4485
ClientLeft = 150
ClientTop = 435
ClientWidth = 4680
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 299
ScaleMode = 3 'Pixel
ScaleWidth = 312
StartUpPosition = 1 '所有者中心
Begin VB.PictureBox P1
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 240
Left = 120
Picture = "Form1.frx":030A
ScaleHeight = 240
ScaleWidth = 240
TabIndex = 9
TabStop = 0 'False
Top = 60
Width = 240
End
Begin VB.Label Label2
BackColor = &H00E0E0E0&
BorderStyle = 1 'Fixed Single
Caption = "0"
BeginProperty Font
Name = "DigitMed"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 315
Left = 480
TabIndex = 8
Top = 60
Width = 1695
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 7
Left = 1200
TabIndex = 7
Top = 3120
Width = 960
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 6
Left = 120
TabIndex = 6
Top = 3120
Width = 960
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 5
Left = 2280
TabIndex = 5
Top = 2040
Width = 960
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 4
Left = 1200
TabIndex = 4
Top = 2040
Width = 960
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 3
Left = 120
TabIndex = 3
Top = 2040
Width = 960
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 2
Left = 2280
TabIndex = 2
Top = 960
Width = 960
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 1
Left = 1200
TabIndex = 1
Top = 960
Width = 960
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 0
Left = 120
TabIndex = 0
Top = 960
Width = 960
End
Begin VB.Menu mnuFile
Caption = "游戏(&G)"
Begin VB.Menu mnuFile_ReStart
Caption = "重新开始(&S)"
Shortcut = ^S
End
Begin VB.Menu mnuAbout
Caption = "关于...(&A)"
End
Begin VB.Menu mnuFile_Exit
Caption = "退出(&X)"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private B(7) As XY, Sc As XY, abX As Byte, abY As Byte, S As Long, CanMove As Boolean
Private Type XY
X As Byte
Y As Byte
End Type
Private Sub Form_Load()
abX = 16
abY = 32
P1.Left = abX
Label2.Left = abX + P1.Width + 8
Me.Width = ((Label1(0).Width + 8) * 3 + abX * 2) * Screen.TwipsPerPixelX
Me.Height = ((Label1(0).Height + 8) * 3 + abY * 2 + 16) * Screen.TwipsPerPixelY
For i = 0 To 7
Label1(i).Caption = " " & i + 1
Next i
Call rStr
End Sub
Private Sub Label1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Xt As Byte, Yt As Byte
Xt = B(Index).X
Yt = B(Index).Y
With Sc
If (((Xt + 1 = .X Or Xt - 1 = .X) And Yt = .Y) Or ((Yt + 1 = .Y Or Yt - 1 = .Y) And Xt = .X)) And CanMove = True Then
With Label1(Index)
.Left = Sc.X * (.Width + 8) + abX
.Top = Sc.Y * (.Height + 8) + abY
End With
B(Index).X = .X
B(Index).Y = .Y
.X = Xt
.Y = Yt
S = S + 1
Label2.Caption = S
End If
For i = 0 To 7
If B(i).X <> i Mod 3 Or B(i).Y <> Int(i / 3) Then Exit For
Next i
If i = 8 Then MsgBox "恭喜恭喜!" & Chr(10) & Chr(13) & "您共移动了" & S & "次,完成了本次游戏。", vbOKOnly + vbInformation, "恭喜": CanMove = False
End With
End Sub
Private Sub Label1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
For i = 0 To 7
Label1(i).BackColor = &H808080
Next i
Label1(Index).BackColor = 0
End Sub
Private Sub mnuAbout_Click()
MsgBox "数字魔方" & Chr(10) & Chr(13) & "Ver:" & App.Major & "." & App.Minor & "." & App.Revision & Chr(10) & Chr(13) & "作者:付浩", vbOKOnly + vbInformation
End Sub
Private Sub mnuFile_Exit_Click()
Unload Me
End
End Sub
Private Sub mnuFile_ReStart_Click()
Call rStr
End Sub
Private Sub rStr()
Dim X As Integer, Y As Integer, n As Byte, i As Byte, P(8) As Boolean
S = 0
Label2.Caption = 0
CanMove = True
For Y = 0 To 2
For X = 0 To 2
n = Int(Rnd * 9)
If P(n) = True Then
X = X - 1
Else
If n = 8 Then
Sc.X = X
Sc.Y = Y
P(n) = True
Else
B(n).X = X
B(n).Y = Y
P(n) = True
Label1(n).Top = GetGY(Y)
Label1(n).Left = GetGX(X)
End If
End If
Next X
Next Y
End Sub
Private Function GetGX(ByVal X As Byte)
GetGX = X * (Label1(0).Width + 8) + abX
End Function
Private Function GetGY(ByVal Y As Byte)
GetGY = Y * (Label1(0).Height + 8) + abY
End Function
Private Sub P1_Click()
Call rStr
End Sub
文件内容:
数字魔方.vbp
Type=Exe
Form=Form1.frm
Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#..\..\..\WINDOWS\SYSTEM\StdOle2.tlb#OLE Automation
IconForm="Form1"
Startup="Form1"
HelpFile=""
Title="数字魔方"
ExeName32="数字魔方.exe"
Path32="..\..\..\WINDOWS\Desktop"
Command32=""
Name="数字魔方"
HelpContextID="0"
CompatibleMode="0"
MajorVer=1
MinorVer=0
RevisionVer=4
AutoIncrementVer=1
ServerSupportFiles=0
VersionCompanyName="PC"
CompilationType=0
OptimizationType=0
FavorPentiumPro(tm)=0
CodeViewDebugInfo=0
NoAliasing=0
BoundsCheck=0
OverflowCheck=0
FlPointCheck=0
FDIVCheck=0
UnroundedFP=0
StartMode=0
Unattended=0
Retained=0
ThreadPerObject=0
MaxNumberOfThreads=1
数字魔方.vbw
Form1 = 53, 100, 423, 447, Z, 64, 25, 434, 372, C
Form1.frm
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "数字魔方"
ClientHeight = 4485
ClientLeft = 150
ClientTop = 435
ClientWidth = 4680
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 299
ScaleMode = 3 'Pixel
ScaleWidth = 312
StartUpPosition = 1 '所有者中心
Begin VB.PictureBox P1
AutoSize = -1 'True
BorderStyle = 0 'None
Height = 240
Left = 120
Picture = "Form1.frx":030A
ScaleHeight = 240
ScaleWidth = 240
TabIndex = 9
TabStop = 0 'False
Top = 60
Width = 240
End
Begin VB.Label Label2
BackColor = &H00E0E0E0&
BorderStyle = 1 'Fixed Single
Caption = "0"
BeginProperty Font
Name = "DigitMed"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00000000&
Height = 315
Left = 480
TabIndex = 8
Top = 60
Width = 1695
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 7
Left = 1200
TabIndex = 7
Top = 3120
Width = 960
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 6
Left = 120
TabIndex = 6
Top = 3120
Width = 960
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 5
Left = 2280
TabIndex = 5
Top = 2040
Width = 960
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 4
Left = 1200
TabIndex = 4
Top = 2040
Width = 960
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 3
Left = 120
TabIndex = 3
Top = 2040
Width = 960
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 2
Left = 2280
TabIndex = 2
Top = 960
Width = 960
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 1
Left = 1200
TabIndex = 1
Top = 960
Width = 960
End
Begin VB.Label Label1
BackColor = &H00808080&
BeginProperty Font
Name = "Arial"
Size = 42
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FFFFFF&
Height = 960
Index = 0
Left = 120
TabIndex = 0
Top = 960
Width = 960
End
Begin VB.Menu mnuFile
Caption = "游戏(&G)"
Begin VB.Menu mnuFile_ReStart
Caption = "重新开始(&S)"
Shortcut = ^S
End
Begin VB.Menu mnuAbout
Caption = "关于...(&A)"
End
Begin VB.Menu mnuFile_Exit
Caption = "退出(&X)"
End
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private B(7) As XY, Sc As XY, abX As Byte, abY As Byte, S As Long, CanMove As Boolean
Private Type XY
X As Byte
Y As Byte
End Type
Private Sub Form_Load()
abX = 16
abY = 32
P1.Left = abX
Label2.Left = abX + P1.Width + 8
Me.Width = ((Label1(0).Width + 8) * 3 + abX * 2) * Screen.TwipsPerPixelX
Me.Height = ((Label1(0).Height + 8) * 3 + abY * 2 + 16) * Screen.TwipsPerPixelY
For i = 0 To 7
Label1(i).Caption = " " & i + 1
Next i
Call rStr
End Sub
Private Sub Label1_MouseDown(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim Xt As Byte, Yt As Byte
Xt = B(Index).X
Yt = B(Index).Y
With Sc
If (((Xt + 1 = .X Or Xt - 1 = .X) And Yt = .Y) Or ((Yt + 1 = .Y Or Yt - 1 = .Y) And Xt = .X)) And CanMove = True Then
With Label1(Index)
.Left = Sc.X * (.Width + 8) + abX
.Top = Sc.Y * (.Height + 8) + abY
End With
B(Index).X = .X
B(Index).Y = .Y
.X = Xt
.Y = Yt
S = S + 1
Label2.Caption = S
End If
For i = 0 To 7
If B(i).X <> i Mod 3 Or B(i).Y <> Int(i / 3) Then Exit For
Next i
If i = 8 Then MsgBox "恭喜恭喜!" & Chr(10) & Chr(13) & "您共移动了" & S & "次,完成了本次游戏。", vbOKOnly + vbInformation, "恭喜": CanMove = False
End With
End Sub
Private Sub Label1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
For i = 0 To 7
Label1(i).BackColor = &H808080
Next i
Label1(Index).BackColor = 0
End Sub
Private Sub mnuAbout_Click()
MsgBox "数字魔方" & Chr(10) & Chr(13) & "Ver:" & App.Major & "." & App.Minor & "." & App.Revision & Chr(10) & Chr(13) & "作者:付浩", vbOKOnly + vbInformation
End Sub
Private Sub mnuFile_Exit_Click()
Unload Me
End
End Sub
Private Sub mnuFile_ReStart_Click()
Call rStr
End Sub
Private Sub rStr()
Dim X As Integer, Y As Integer, n As Byte, i As Byte, P(8) As Boolean
S = 0
Label2.Caption = 0
CanMove = True
For Y = 0 To 2
For X = 0 To 2
n = Int(Rnd * 9)
If P(n) = True Then
X = X - 1
Else
If n = 8 Then
Sc.X = X
Sc.Y = Y
P(n) = True
Else
B(n).X = X
B(n).Y = Y
P(n) = True
Label1(n).Top = GetGY(Y)
Label1(n).Left = GetGX(X)
End If
End If
Next X
Next Y
End Sub
Private Function GetGX(ByVal X As Byte)
GetGX = X * (Label1(0).Width + 8) + abX
End Function
Private Function GetGY(ByVal Y As Byte)
GetGY = Y * (Label1(0).Height + 8) + abY
End Function
Private Sub P1_Click()
Call rStr
End Sub