📄 form1.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form Form1
AutoRedraw = -1 'True
BackColor = &H8000000C&
BorderStyle = 0 'None
Caption = "Form1"
ClientHeight = 9000
ClientLeft = 0
ClientTop = 0
ClientWidth = 12000
Icon = "Form1.frx":0000
KeyPreview = -1 'True
LinkTopic = "Form1"
Picture = "Form1.frx":030A
ScaleHeight = 600
ScaleMode = 3 'Pixel
ScaleWidth = 800
ShowInTaskbar = 0 'False
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer3
Index = 0
Interval = 1000
Left = 2640
Top = 4080
End
Begin VB.Timer Timer2
Interval = 2000
Left = 3840
Top = 2760
End
Begin MSComctlLib.ProgressBar Pt
Height = 255
Left = 120
TabIndex = 3
Top = 360
Width = 1575
_ExtentX = 2778
_ExtentY = 450
_Version = 393216
Appearance = 0
Max = 6
Scrolling = 1
End
Begin VB.Timer TM
Index = 0
Interval = 100
Left = 6600
Top = 5640
End
Begin VB.Timer Timer1
Interval = 1000
Left = 6360
Top = 4320
End
Begin MSComctlLib.ImageList Foe
Left = 4560
Top = 3720
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 61
ImageHeight = 50
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 2
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":C1EB
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":CDE7
Key = ""
EndProperty
EndProperty
End
Begin MSComctlLib.ImageList il
Left = 3240
Top = 3600
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 61
ImageHeight = 50
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 2
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":D9EB
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Form1.frx":E403
Key = ""
EndProperty
EndProperty
End
Begin VB.Line FD
BorderColor = &H000000FF&
BorderWidth = 3
Index = 0
Visible = 0 'False
X1 = 184
X2 = 208
Y1 = 208
Y2 = 208
End
Begin VB.Label Fl
Caption = "3"
Height = 615
Index = 0
Left = 2760
TabIndex = 2
Top = 1440
Visible = 0 'False
Width = 1095
End
Begin VB.Image F
Height = 750
Index = 4
Left = 600
Picture = "Form1.frx":EE1F
Top = 7920
Width = 915
End
Begin VB.Image F
Height = 750
Index = 3
Left = 3840
Picture = "Form1.frx":FA0B
Top = 7920
Width = 915
End
Begin VB.Image F
Height = 750
Index = 2
Left = 7080
Picture = "Form1.frx":105F7
Top = 7920
Width = 915
End
Begin VB.Image F
Height = 750
Index = 1
Left = 10200
Picture = "Form1.frx":111E9
Top = 7800
Width = 915
End
Begin VB.Label Label2
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "30 发"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FF00&
Height = 210
Left = 1080
TabIndex = 1
Top = 120
Width = 525
End
Begin VB.Label Label1
AutoSize = -1 'True
BackStyle = 0 'Transparent
Caption = "重型炮弹:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FF00&
Height = 210
Left = 120
TabIndex = 0
Top = 120
Width = 945
End
Begin VB.Image F
Height = 750
Index = 0
Left = 10200
Picture = "Form1.frx":11DDB
Top = 3360
Width = 915
End
Begin VB.Line L
BorderColor = &H000080FF&
BorderWidth = 3
Index = 0
Visible = 0 'False
X1 = 88
X2 = 128
Y1 = 248
Y2 = 248
End
Begin VB.Image P
Height = 750
Left = 240
Picture = "Form1.frx":129CD
Top = 3360
Width = 915
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'
'本程序作者:周金锋
'
'E-mail: JinFeng82@163.net
'
'主页: Http://JinFengnet.yeah.net
'
'这是作者编写的第一个游戏,还有很多不足之处,忠心希望各位VB高手多多指教。
'
'由于作者的美术水平实在太差,所以...
'
'欢迎光临《金锋编程园地》- 网址: Http://JinFengnet.yeah.net
'
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Dim PH, Pl As Boolean
Dim Ft(4) As Boolean
Dim UN As Boolean
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next
Dim Ky
Ky = KeyCode
Select Case Ky
Case 27 '按下[ESC]键退出
If MsgBox("真的要退出吗?", vbYesNo + 32, "坦克大战") = vbYes Then End
Case 32 '按下 空格键 发射轻型炮弹
Load L(L.Count)
L(L.Count - 1).X1 = P.Left + P.Width
L(L.Count - 1).X2 = L(L.Count - 1).X1 + 5
L(L.Count - 1).Y1 = P.Top + P.Height / 3
L(L.Count - 1).Y2 = L(L.Count - 1).Y1
L(L.Count - 1).BorderColor = &HFFFF&
L(L.Count - 1).BorderWidth = 3
sndPlaySound PH & "MS4.wav", &H1
If Pl = True Then
MV (L.Count - 1)
Else
L(L.Count - 1).X2 = P.Left
L(L.Count - 1).X1 = P.Left - 5
MV1 (L.Count - 1)
End If
Case 39
If GetPixel(hdc, P.Left + P.Width + 5, P.Top + P.Height / 2) = 8421504 Then
If Pl = False Then
P.Picture = il.ListImages(1).Picture
Pl = True
End If
P.Left = P.Left + 7
End If
Case 40
If GetPixel(hdc, P.Left + P.Width / 2, P.Top + P.Height + 2) = 8421504 Then
P.Top = P.Top + 3
End If
Case 37
If GetPixel(hdc, P.Left - 5, P.Top + P.Height / 2) = 8421504 Then
If Pl = True Then
P.Picture = il.ListImages(2).Picture
Pl = False
End If
P.Left = P.Left - 7
End If
Case 38
If GetPixel(hdc, P.Left + P.Width / 2, P.Top - 2) = 8421504 Then
P.Top = P.Top - 3
End If
Case 17 '按下 [Ctrl] 键发射重型炮弹
Cnt = Val(Label2.Caption)
If Cnt <= 0 Then GoTo p8 '如果重型炮弹剩余为 0 'label2'闪烁一次
Load L(L.Count)
Cnt = Cnt - 1 '炮弹数量减 1
Label2.Caption = Cnt & " 发"
L(L.Count - 1).X1 = P.Left + P.Width
L(L.Count - 1).X2 = L(L.Count - 1).X1 + 5
L(L.Count - 1).Y1 = P.Top + P.Height / 3
L(L.Count - 1).Y2 = L(L.Count - 1).Y1
L(L.Count - 1).BorderColor = &H80FF&
L(L.Count - 1).BorderWidth = 8
sndPlaySound PH & "MS3.wav", &H1
If Pl = True Then
BMV (L.Count - 1)
Else
L(L.Count - 1).X2 = P.Left
L(L.Count - 1).X1 = P.Left - 5
BMV1 (L.Count - 1)
End If
End Select
Exit Sub
p8:
For i = 1 To 3000
DoEvents
Label2.Visible = False
DoEvents
Next
Label2.Visible = True
End Sub
Private Sub Form_Load()
Randomize Timer
SetDisplayMode 800, 600, 16 '屏幕设置为 800 × 600 × 16 位
Me.Move 0, 0, Screen.Width, Screen.Height
Pl = True
If Right$(App.Path, 1) = "\" Then PH = App.Path Else PH = App.Path & "\" '设置 "PH" 值为程序所在目录
For i = 1 To 4
Load TM(i)
TM(i).Enabled = True
TM(i).Interval = 100
Next
For i = 1 To 4
Load Fl(i)
Fl(i).Caption = 3
Next
Pt.Value = 6
For i = 0 To 2
Ft(i) = False
Next
Ft(3) = True
Ft(4) = True
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -