網路城邦
回本城市首頁 唐老鴨之家
市長:  副市長:
加入本城市推薦本城市加入我的最愛訂閱最新文章
udn城市資訊科技網路分享【唐老鴨之家】城市/討論區/
討論區VB6 字體:
上一個討論主題 回文章列表 下一個討論主題
吹泡泡VB程式
 瀏覽629|回應0推薦0


等級:6
留言加入好友
Rem === 吹泡泡程式 ===
Private Type point: X As Single: Y As Single: size As Single: color As Long: alive As Boolean: End Type
Const pi = 3.14159
Dim p() As point

Private Sub Form_KeyPress(KeyAscii As Integer): If KeyAscii = 27 Then Unload Form1
End Sub

Private Sub Form_Load()
Form1.WindowState = 2: Form1.Show: Form1.AutoRedraw = True
Form1.BackColor = vbBlack: Form1.FillStyle = 1
ReDim p(0)
Dim t1 As Single: t1 = Timer
Do
If Abs(t1 - Timer) > 0.01 Then
t1 = Timer: Cls
For i = 0 To UBound(p)
With p(i)
If .alive = True Then
Form1.FillStyle = 1
Circle (.X, .Y), .size, QBColor(.color)
Circle (.X, .Y), .size * 0.8, vbWhite, pi * 0.9, pi * 1.2
Circle (.X, .Y), .size * 0.7, vbWhite, pi * 0.9, pi * 1.2
Form1.ForeColor = QBColor(IIf(.color < 7, .color + 8, 15))
Circle (.X - Sin(0.8 * pi) * .size * 0.8, .Y + Cos(0.8 * pi) * .size * 0.5), .size * 0.1
.X = .X - (Rnd * 100 - 50): .Y = .Y - (Rnd * 50): .size = .size - Rnd * 10
If .size < Screen.TwipsPerPixelX Then .alive = False
End If
End With
Next i
End If
DoEvents
Loop
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Randomize Timer
For i = 0 To UBound(p)
If p(i).alive = False Then With p(i): .X = X: .Y = Y: .color = (Int(Rnd * 15 + 1)): .size = Int(Rnd * 500 + 200): .alive = True: End With: Exit For
Next i
If i = UBound(p) + 1 Then
ReDim Preserve p(i)
With p(i): .X = X: .Y = Y: .color = (Int(Rnd * 15 + 1)): .size = Int(Rnd * 500 + 200): .alive = True: End With
End If
End If
End Sub

Private Sub Form_Unload(Cancel As Integer): End
End Sub

本文於 修改第 1 次
回應 回應給此人 推薦文章 列印 加入我的文摘

引用
引用網址:https://city.udn.com/forum/trackback.jsp?no=58536&aid=4316114