
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
B.Left += Vx
B.Top += Vy
If B.Left < 0 Then
Vx = Math.Abs(Vx)
End If
If B.Right > Me.ClientSize.Width Then
Vx = -Math.Abs(Vx)
End If
If B.Top < 0 Then
Vy = Math.Abs(Vy)
End If
If B.Bottom > P.Top Then
Dim C As Integer = (B.Left + B.Right) / 2
If C >= P.Left AndAlso C <= P.Right Then
Dim F As Double = (CDbl(C) - CDbl(P.Left)) / CDbl(P.Width)
If Vx < 0 Then
F = (1.0 - F)
End If
F = F + 0.5
Vx = CInt(Math.Round(Vx * F))
Vy = -Math.Abs(Vy)
Score = Score + 10
Me.Text = "分数:" & Score.ToString()
Else
If B.Bottom > Me.ClientSize.Height Then
Timer1.Stop()
MsgBox("Game Over!", , "提示")
B.Left = 220
B.Top = 200
Score = 0
Vx = 5
Vy = 5
Me.Text = "分数:" & Score.ToString()
End If
End If
End If
End Sub
B.Left += Vx
B.Top += Vy
If B.Left < 0 Then
Vx = Math.Abs(Vx)
End If
If B.Right > Me.ClientSize.Width Then
Vx = -Math.Abs(Vx)
End If
If B.Top < 0 Then
Vy = Math.Abs(Vy)
End If
If B.Bottom > P.Top Then
Dim C As Integer = (B.Left + B.Right) / 2
If C >= P.Left AndAlso C <= P.Right Then
Dim F As Double = (CDbl(C) - CDbl(P.Left)) / CDbl(P.Width)
If Vx < 0 Then
F = (1.0 - F)
End If
F = F + 0.5
Vx = CInt(Math.Round(Vx * F))
Vy = -Math.Abs(Vy)
Score = Score + 10
Me.Text = "分数:" & Score.ToString()
Else
If B.Bottom > Me.ClientSize.Height Then
Timer1.Stop()
MsgBox("Game Over!", , "提示")
B.Left = 220
B.Top = 200
Score = 0
Vx = 5
Vy = 5
Me.Text = "分数:" & Score.ToString()
End If
End If
End If
End Sub
