主题:[原创]漫天飞雪——控件数组的应用
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 7530
ClientLeft = 60
ClientTop = 450
ClientWidth = 9480
LinkTopic = "Form1"
ScaleHeight = 7530
ScaleWidth = 9480
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Left = 4200
Top = 3480
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Snow(1000, 2)
Const Amounty = 200 '雪花数量
Private Sub Form_Click()
End
End Sub
Private Sub Form_Load()
Form1.Show
Me.BackColor = RGB(40, 40, 80) '背景色
Randomize
For i = 1 To Amounty
Snow(i, 0) = Int(Rnd * Width) '水平位置
Snow(i, 1) = Int(Rnd * Height) '垂直位置
Snow(i, 2) = (10 + (Rnd * 20)) '速度
Next i
Timer1.Interval = 50
End Sub
Private Sub Timer1_Timer()
For i = 1 To Amounty '一朵
OldX = Snow(i, 0)
OldY = Snow(i, 1)
Snow(i, 1) = Snow(i, 1) + Snow(i, 2) '垂直动一格
If Snow(i, 1) > Form1.Height Then '到底了,重新产生一朵
Snow(i, 1) = 0
Snow(i, 2) = 5 + (Rnd * 30)
Snow(i, 0) = Int(Rnd * Form1.Width)
End If
Coloury = 8 * (Snow(i, 2) - 10) + 60 '越远越慢颜色越深
DrawWidth = Snow(i, 2) / 2
PSet (OldX, OldY), Me.BackColor
PSet (Snow(i, 0), Snow(i, 1)), RGB(Coloury, Coloury, Coloury)
Next i
End Sub
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 7530
ClientLeft = 60
ClientTop = 450
ClientWidth = 9480
LinkTopic = "Form1"
ScaleHeight = 7530
ScaleWidth = 9480
StartUpPosition = 3 '窗口缺省
Begin VB.Timer Timer1
Left = 4200
Top = 3480
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Snow(1000, 2)
Const Amounty = 200 '雪花数量
Private Sub Form_Click()
End
End Sub
Private Sub Form_Load()
Form1.Show
Me.BackColor = RGB(40, 40, 80) '背景色
Randomize
For i = 1 To Amounty
Snow(i, 0) = Int(Rnd * Width) '水平位置
Snow(i, 1) = Int(Rnd * Height) '垂直位置
Snow(i, 2) = (10 + (Rnd * 20)) '速度
Next i
Timer1.Interval = 50
End Sub
Private Sub Timer1_Timer()
For i = 1 To Amounty '一朵
OldX = Snow(i, 0)
OldY = Snow(i, 1)
Snow(i, 1) = Snow(i, 1) + Snow(i, 2) '垂直动一格
If Snow(i, 1) > Form1.Height Then '到底了,重新产生一朵
Snow(i, 1) = 0
Snow(i, 2) = 5 + (Rnd * 30)
Snow(i, 0) = Int(Rnd * Form1.Width)
End If
Coloury = 8 * (Snow(i, 2) - 10) + 60 '越远越慢颜色越深
DrawWidth = Snow(i, 2) / 2
PSet (OldX, OldY), Me.BackColor
PSet (Snow(i, 0), Snow(i, 1)), RGB(Coloury, Coloury, Coloury)
Next i
End Sub