📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 4725
ClientLeft = 60
ClientTop = 450
ClientWidth = 5940
LinkTopic = "Form1"
ScaleHeight = 4725
ScaleWidth = 5940
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton Command2
Caption = "退出"
Height = 375
Left = 4680
TabIndex = 4
Top = 3960
Width = 975
End
Begin VB.CommandButton Command1
Caption = "开始"
Height = 375
Left = 3240
TabIndex = 3
Top = 3960
Width = 975
End
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 200
Left = 480
Top = 3960
End
Begin VB.PictureBox Picture1
Height = 3255
Left = 240
ScaleHeight = 3195
ScaleWidth = 5355
TabIndex = 0
Top = 240
Width = 5415
Begin VB.Line Line1
BorderWidth = 5
X1 = 960
X2 = 4080
Y1 = 2880
Y2 = 2880
End
Begin VB.Shape Shape1
FillColor = &H000000FF&
FillStyle = 0 'Solid
Height = 615
Left = 1920
Shape = 3 'Circle
Top = 240
Width = 855
End
End
Begin VB.Label Label2
Caption = "0"
Height = 255
Left = 2280
TabIndex = 2
Top = 4080
Width = 735
End
Begin VB.Label Label1
Caption = "得分:"
Height = 375
Left = 1560
TabIndex = 1
Top = 4080
Width = 615
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim x_step As Integer
Dim y_step As Integer
Private Sub Command1_Click()
Timer1.Enabled = Not Timer1.Enabled
If Command1.Caption = "暂停" Then
Command1.Caption = "继续"
Else
Command1.Caption = "暂停"
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
x_step = 200
y_step = 200
End Sub
Private Sub Picture1_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 37
If Line1.X1 <= 0 Then
Line1.X1 = 0
Line1.X2 = 2000
Else
Line1.X1 = Line1.X1 - 100
Line1.X2 = Line1.X2 - 100
End If
Case 39
If Line1.X2 >= Picture1.Width Then
Line1.X2 = Picture1.Width
Line1.X1 = Picture1.Width - 2000
Else
Line1.X1 = Line1.X1 + 100
Line1.X2 = Line1.X2 + 100
End If
End Select
End Sub
Private Sub Timer1_Timer()
If Shape1.Top <= 0 Then Shape1.Top = 0: y_step = -y_step
If Shape1.Left <= 0 Then Shape1.Left = 0: x_step = -x_step
If Shape1.Left >= Picture1.Width - Shape1.Width Then
Shape1.Left = Picture1.Width - Shape1.Width
x_step = -x_step
End If
If Shape1.Top >= Line1.Y1 - Shape1.Height And Shape1.Left >= Line1.X1 And Shape1.Left <= Line1.X2 Then
Shape1.Top = Line1.Y1 - Shape1.Height
y_step = -y_step
x_step = x_step * 1.01
Label2.Caption = Val(Label2.Caption) + 1
End If
Shape1.Top = Shape1.Top + y_step
Shape1.Left = Shape1.Left + x_step
If Shape1.Top >= Picture1.Height - Shape1.Height Then
MsgBox "你输了!"
Timer1.Enabled = False
Command1.Caption = "开始"
Shape1.Top = 1000
Label2.Caption = 0
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -