📄 game.frm
字号:
VERSION 5.00
Begin VB.Form frmgame
AutoRedraw = -1 'True
BackColor = &H00EFF2EC&
BorderStyle = 1 'Fixed Single
Caption = "BLacK Impact"
ClientHeight = 8145
ClientLeft = 150
ClientTop = 510
ClientWidth = 6885
FillStyle = 0 'Solid
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Icon = "Game.frx":0000
KeyPreview = -1 'True
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
MousePointer = 99 'Custom
ScaleHeight = 8145
ScaleWidth = 6885
StartUpPosition = 2 'CenterScreen
Begin VB.Timer Timer1
Interval = 1
Left = 4200
Top = 120
End
Begin VB.Image imgBBulletMask
Height = 120
Left = 6360
Picture = "Game.frx":628A
Top = 2040
Visible = 0 'False
Width = 120
End
Begin VB.Image imgBBullet
Height = 120
Left = 6240
Picture = "Game.frx":638C
Top = 2040
Visible = 0 'False
Width = 120
End
Begin VB.Image imgSmallRapMask
Height = 375
Left = 5160
Picture = "Game.frx":648E
Top = 4080
Visible = 0 'False
Width = 330
End
Begin VB.Image imgSmallRap
Height = 375
Left = 4800
Picture = "Game.frx":6B74
Top = 4080
Visible = 0 'False
Width = 330
End
Begin VB.Image imgExplodeMask
Height = 465
Left = 6120
Picture = "Game.frx":725A
Top = 4080
Visible = 0 'False
Width = 450
End
Begin VB.Image imgExplode
Height = 465
Left = 5640
Picture = "Game.frx":7DC0
Top = 4080
Visible = 0 'False
Width = 450
End
Begin VB.Image imgBullet2
Height = 60
Left = 4320
Picture = "Game.frx":8926
Top = 2880
Visible = 0 'False
Width = 60
End
Begin VB.Image imgBullet1
Height = 60
Left = 4440
Picture = "Game.frx":8998
Top = 2880
Visible = 0 'False
Width = 60
End
Begin VB.Image imgRapMask
Height = 885
Left = 5760
Picture = "Game.frx":8A0A
Top = 3120
Visible = 0 'False
Width = 780
End
Begin VB.Image imgRap
Height = 885
Left = 5040
Picture = "Game.frx":AE40
Top = 3120
Visible = 0 'False
Width = 780
End
Begin VB.Image imgBadGuy
Height = 720
Left = 5280
Picture = "Game.frx":D276
Top = 2040
Visible = 0 'False
Width = 825
End
Begin VB.Image imgRapFire
Height = 885
Left = 5760
Picture = "Game.frx":F238
Top = 4680
Visible = 0 'False
Width = 780
End
Begin VB.Image imgRapFireMask
Height = 885
Left = 5040
Picture = "Game.frx":1166E
Top = 4680
Visible = 0 'False
Width = 780
End
Begin VB.Image imgBadGuyMask
Height = 720
Left = 4440
Picture = "Game.frx":13AA4
Top = 2040
Visible = 0 'False
Width = 825
End
Begin VB.Image imgBackGround
Height = 1800
Left = 1440
Picture = "Game.frx":15A66
Top = 2400
Visible = 0 'False
Width = 1800
End
End
Attribute VB_Name = "frmgame"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const MaxBadGuys = 4 'Max Number of Bad Guys on the Screen (Keep this number small)
Const MaxBullets = 25 'Max Number of Bullets you can fire
Const MaxEnemyBullets = 25 'Max Number of Bullets the enemy can fire
Const MaxAccel = 100 'Max Acceleration of Your Plane
Const EnemyFireInterval = 50 'The interval at which enemys will shoot
Const EnemySpeed = 75 'Speed at which enemies move
Public Backy As Long 'Position of the Background
Public gX As Long 'Global X position of your plane
Public gY As Long 'Global y position of your plane
Public XV As Long 'Velocity in the X direction
Public YV As Long 'Velocity in the Y direction
Public MouseX As Long 'Mouse X position
Public MouseY As Long 'Mouse Y position
Public SpaceIsPressed As Boolean 'Indicates that the space bar is pressed (fire)
Dim BadX(1 To MaxBadGuys) As Long 'Bad Guy X positions
Dim BadY(1 To MaxBadGuys) As Long 'Bad Guy Y positions
Dim BulletX(1 To MaxBullets) As Long 'BulletX positions
Dim BulletY(1 To MaxBullets) As Long 'BulletY positions
Dim BBulletX(1 To MaxEnemyBullets) As Long 'Bad Guy Bullet X positions
Dim BBulletY(1 To MaxEnemyBullets) As Long 'Bad Guy BUllet Y positions
Dim BulletCount As Long 'Number of bullets fired
Dim FireToggle As Boolean 'Toggles the flames comming out of the wings from your guns
Dim BulletToggle As Boolean 'Toggles the bullets direction
Public StartBullet As Integer 'The starting counter for bullets
Public CurrBullet As Integer 'The current bullet last fired
Public BCurrBullet As Integer 'Bad Guy current bullet last fired
Public Score As Long 'Current Score
Public Lives As Integer 'Number of Lives you have left
Public BBuletTimer As Integer 'Counter for enemy firing
Public EFireCount As Integer 'Counter for enemy firing
Public BeginGame As Boolean 'Indicates to begin the game
Public Shields As Long 'Amount of shields left on your ship
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Dim i As Integer
Select Case KeyCode
Case vbKeySpace
SpaceIsPressed = True
If BeginGame = False Then
BeginGame = True
gX = Me.Width / 2 - Me.imgRap.Width / 2
gY = Me.Height - Me.imgRap.Height - 300
For i = 1 To MaxBadGuys 'position of the bad guys
BadX(i) = Rnd * Me.Width
BadY(i) = (Rnd * Me.Height) - Me.Height
Next
StartBullet = 1
Lives = 3
For i = 1 To MaxBullets
BulletY(i) = -100
Next
For i = 1 To MaxEnemyBullets
BBulletY(i) = Me.Height
Next
SpaceIsPressed = False
Me.Shields = 4000
Score = 0
End If
Case vbKeyF2
BeginGame = True
gX = Me.Width / 2 - Me.imgRap.Width / 2
gY = Me.Height - Me.imgRap.Height - 300
For i = 1 To MaxBadGuys 'position of the bad guys
BadX(i) = Rnd * Me.Width
BadY(i) = (Rnd * Me.Height) - Me.Height
Next
StartBullet = 1
Lives = 3
For i = 1 To MaxBullets
BulletY(i) = -100
Next
For i = 1 To MaxEnemyBullets
BBulletY(i) = Me.Height
Next
SpaceIsPressed = False
Me.Shields = 4000
Me.Timer1.interval = 1
Score = 0
Case vbKeyP
If Me.Timer1.interval = 0 Then
Me.Timer1.interval = 1
Else
Me.Timer1.interval = 0
Me.FontSize = 28
Me.CurrentX = Me.Width / 2 - Me.TextWidth("Paused") / 2
Me.CurrentY = Me.Height / 2 - 2000
Me.Print "Paused"
End If
End Select
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -