弹球游戏
Dim x_step As Integer
Dim y_step As Integer
Private Sub command1_Click()
If Timer1.Enabled = True Then
Timer1.Enabled = False
Else
Timer1.Enabled = True
End If
If command1.Caption = "暂停" Then
command1.Caption = "继续"
Else
command1.Caption = "暂停"
End If
End Sub
Private Sub Form_Load()
x_step = 200
y_step = 200
End Sub
Private Sub Picture1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 37 Then
If Line1.X1 < 0 Then
Line1.X1 = 0: Line1.X2 = 2000
Else
Line1.X1 = Line1.X1 - 100: Line1.X2 = Line1.X2 - 100
End If
End If
If KeyCode = 39 Then
If Line1.X1 > Picture1.Width Then
Line1.X1 = Picture1.Width - 2000: line2.X2 = Picture.Width
Else
Line1.X1 = Line1.X1 + 100: Line1.X2 = Line1.X2 + 100
End If
End If
End Sub
Private Sub Timer1_Timer()
If Shape1.Top < 0 Then
Shape1.Top = 0: y_step = -y_step
End If
If Shape1.Left < 0 Then
Shape1.Left = 0
x_step = -x_step
End If
If Shape1.Left > Picture1.Width - Shape1.Width Then
Shape1.Left = Picture1.Width - Shape1.Width
x_step =