解决方案显示的可见部分包含一个椭圆,该椭圆与右侧的表单边框交叉并立即出现在左侧。我用两个省略号编写了代码。我需要一个提示,如果解决方案只能用一个椭圆书写。无需添加其他控件即可复制和粘贴代码。
Public Class Form1
Dim WithEvents t As New Timer() With {.Interval = 50}
Dim UFO As Integer
Dim reachTheotherSide As Integer
Dim counter As Integer
Private Sub t_Tick(sender As Object, e As EventArgs) Handles t.Tick
reachTheotherSide += 1
counter += 1
If reachTheotherSide >= 198 Then
UFO += 1
End If
If reachTheotherSide >= 250 And UFO = 45 Then
reachTheotherSide = 45
End If
If UFO = 45 Then
UFO = -87
End If
If counter = 285 Then
Threading.Thread.Sleep(1000)
counter = 0
End If
Me.Invalidate()
End Sub
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
DoubleBuffered = True
CenterToScreen()
t.Start()
UFO = -87
reachTheotherSide = 45
End Sub
Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
e.Graphics.DrawEllipse(New Pen(Color.Black, 0), UFO, 87, 86, 86)
e.Graphics.DrawEllipse(New Pen(Color.Black, 0), reachTheotherSide, 87, 86, 86)
End Sub
End Class