关于在vb中做3个动圆的问题
最近在做一个用vb在窗体做3个动圆,这三个圆碰到边界后反弹回去。要求用classmodule做。。这部分代码已经有了,下面不知道该咋做了。。那位帮忙给整下。。我vb太菜了。 在线急等Option Explicit
Private Name As String
Private intFormIndex As Integer
Private sglX As Single
Private sglY As Single
Private sglXspeed As Single
Private sglYspeed As Single
Private sglRadius As Single
Public Visible As Boolean
Public Sub Initialize(FormName As String, Optional Top As Single = 1, Optional Left As Single = 1)
Dim frmBuf As Form
For Each frmBuf In Forms
If frmBuf.Name = FormName Then
Exit For
End If
intFormIndex = intFormIndex + 1
Next
sglX = Top
sglY = Left
sglRadius = 10
sglXspeed = 0.1
sglYspeed = 0.1
Forms(intFormIndex).ScaleMode = vbMillimeters
Visible = True
End Sub
Public Sub WriteCircle(Top As Single, Left As Single)
If Not Visible Then Exit Sub
sglX = Top
sglY = Left
frmMain.FillStyle = 0
frmMain.FillColor = vbGreen
frmMain.Circle (sglX, sglY), sglRadius
End Sub
Public Property Let X(Xpos As Single)
sglX = Xpos
End Property
Public Property Get X() As Single
X = sglX
End Property
Public Property Let Y(Ypos As Single)
sglY = Ypos
End Property
Public Property Get Y() As Single
Y = sglY
End Property
Public Property Let XSpeed(Xpos As Single)
If Xpos < -10 Or Xpos > 10 Then
Err.Raise 10000, "", "请输入-10到10之间的数字。"
End If
sglXspeed = Xpos
End Property
Public Property Get XSpeed() As Single
XSpeed = sglXspeed
End Property
Public Property Let YSpeed(Ypos As Single)
If Ypos < -10 Or Ypos > 10 Then
Err.Raise 10000, "", "请输入-10到10之间的数字。"
End If
sglYspeed = Ypos
End Property
Public Property Get YSpeed() As Single
YSpeed = sglYspeed
End Property