首页 »VB教程 » vb窗体:VB实现在窗体上实现类似于下雪的场景 »正文
vb窗体:VB实现在窗体上实现类似于下雪的场景
来源: 发布时间:星期四, 2009年1月15日 浏览:28次 评论:0
Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As .EventArgs) Handles Timer1.Tick Dim Snow(1000, 2), Amounty As Integer Dim Oldx, Oldy As Integer Dim Coloury As Integer Dim Chg As Boolean Static c As Integer = 0 If Chg Then c = c - 20 Else c = c + 20 End If If c > 255 Then Chg = True c = c - 20 End If If c < 10 Then Chg = False c = c + 20 End If Label1.ForeColor = .Drawing.Color.FromArgb(c, c, c) Dim a As .Drawing.Graphics a = Me.CreateGraphics Me.Show .Windows.Forms.Application.DoEvents Randomize Amounty = 325 Dim J, I, LS As Integer For j = 1 To Amounty Snow(J, 0) = Int(Rnd * Me.Width) Snow(J, 1) = Int(Rnd * Me.Height) Snow(J, 2) = Rnd * 20 + 10 Next Randomize For LS = 1 To 10 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) > Me.Height Then Snow(I, 1) = 0 Snow(I, 2) = 5 + (Rnd * 30) Snow(I, 0) = Int(Rnd * Me.Width) Oldx = 0 Oldy = 0 End If Coloury = 8 * (Snow(I, 2) - 10) Coloury = 60 + Coloury If Coloury > 255 Then Coloury = 0 End If Dim p As New .Drawing.Pen(Color.FromArgb(0)) a.DrawEllipse(p, Oldx, Oldy, 3, 3) p = New .Drawing.Pen(Color.FromArgb(Coloury, Coloury, Coloury)) a.DrawEllipse(p, Snow(I, 0), Snow(I, 1), 3, 3) Next Me.Refresh Next End Sub
相关文章
读者评论
发表评论
|
|