Hiệu ứng như lao trong vũ trụ

Các thủ thuật về âm thanh, đồ họa, truyền thông đa phương tiện...
Đăng trả lời
QuangHoa
Guru
Guru
Bài viết: 542
Ngày tham gia: Thứ 5 27/03/2008 9:02 am
Đến từ: Quê hương Đại tướng Võ Nguyên Giáp
Been thanked: 5 times
Tiếp xúc:

Hiệu ứng như lao trong vũ trụ

Gửi bài by QuangHoa »

Thủ thuật: Hiệu ứng như lao trong vũ trụ
Tác giả: Sưu tầm
Mô tả: Hiệu ứng như lao trong vũ trụ
Tôi đã chỉnh lại chút để Code gọn hơn và bạn chỉ cần thêm một Comand và một timer vào thôi, dán Code vào và F5

Mã: Chọn tất cả

Private W As IntegerPrivate H As IntegerPrivate Type Stars x As Double y As Integer AddX As Integer AddY As IntegerEnd TypePrivate Star(1000) As StarsPrivate Accelarate As BooleanPrivate Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As LongPrivate Sub Command1_Click()Timer1.Interval = 1MoveTo = move_forwardCommand1.Visible = FalseAccelarate = FalseWindowState = 2W = ScaleWidthH = ScaleHeight For i = 1 To 150  Star(i).x = W / 2  Star(i).y = H / 2RandomX:  Randomize  Star(i).AddX = Int(Rnd * 29) - Int(Rnd * 29)  If Star(i).AddX = 0 Then GoTo RandomXRandomY:  Star(i).AddY = Int(Rnd * 19) - Int(Rnd * 19)  If Star(i).AddY = 0 Then GoTo RandomY NextEnd SubPrivate Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)If KeyCode = vbKeyEscape Then EndEnd SubPrivate Sub Form_Load()Me.BorderStyle = 0Me.DrawWidth = 5Me.ScaleMode = 3Me.BackColor = &H80000007Me.WindowState = 2End SubPrivate Sub Timer1_Timer()If Command1.Visible = True Then Exit SubFor i = 1 To 150 SetPixel hdc, W / 2, H / 2, &H404040 Select Case Abs(W / 2 - (Star(i).x))  Case Is < 20   col = &H0&   Size = 1  Case Is < 80   col = &H404040   Size = 1  Case Is < 150   col = &H808080   Size = 2  Case Is < 200   col = &HC0C0C0   Size = 3  Case Is < 250   col = &HFFFFFF   Size = 4  Case Else   col = &HFFFFFF   Size = 5 End Select Select Case Abs(H / 2 - (Star(i).y))  Case Is < 20   If Size = 0 Then    Size = 1    col = back5   End If  Case Is < 80   If Size = 0 Then    col = &H404040    Size = 1   End If  Case Is < 150   If Size < 2 Then    Size = 2    col = &H808080   End If  Case Is < 200   If Size < 3 Then    Size = 3    col = &HC0C0C0   End If  Case Is < 250   If Size < 4 Then    Size = 4    col = &HFFFFFF   End If  Case Else   If Size < 5 Then    Size = 5    col = &HFFFFFF   End If End SelectSetPixel hdc, W / 2, H / 2, colSelect Case Size Case 1  SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&  SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col Case 2  SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&  SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&  SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col  SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col Case 3  SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&  SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&  SetPixel Me.hdc, Star(i).x - 1, Star(i).y - 1, &H0&  SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col  SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col  SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col Case 4  SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&  SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&  SetPixel Me.hdc, Star(i).x - 1, Star(i).y - 1, &H0&  SetPixel Me.hdc, Star(i).x, Star(i).y - 1, &H0&  SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col  SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col  SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col  SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col Case 5  SetPixel Me.hdc, Star(i).x + a, Star(i).y, &H0&  SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y, &H0&  SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y - 1, &H0&  SetPixel Me.hdc, Star(i).x + a, Star(i).y - 1, &H0&  SetPixel Me.hdc, Star(i).x + a, Star(i).y - 2, &H0&  SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y - 2, &H0&  SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col  SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col  SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col  SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col  SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 2 + Star(i).AddY, col  SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 2 + Star(i).AddY, colEnd SelectStar(i).x = Star(i).x + Star(i).AddXStar(i).y = Star(i).y + Star(i).AddYStar(i).AddX = Star(i).AddX + Sgn(Star(i).AddX) * (Size / 5)Star(i).AddY = Star(i).AddY + Sgn(Star(i).AddY) * (Size / 5)If Accelarate Then Star(i).AddX = Star(i).AddX + Sgn(Star(i).AddX) * Size Star(i).AddY = Star(i).AddY + Sgn(Star(i).AddY) * SizeEnd IfIf Star(i).x < 0 Or Star(i).x > ScaleWidth Or Star(i).y < 0 Or Star(i).y > ScaleHeight Then  Star(i).x = W / 2  Star(i).y = H / 2RandomX:  Randomize  Star(i).AddX = Int(Rnd * 29) - Int(Rnd * 29)  If Star(i).AddX = 0 Then GoTo RandomXRandomY:  Star(i).AddY = Int(Rnd * 19) - Int(Rnd * 19)  If Star(i).AddY = 0 Then GoTo RandomYEnd IfNextEnd Sub 
朋友
这些年一个人风也过雨也走,有过泪有过错还记得坚持什么。
真爱过才会懂会记没会回手,终有梦中有你在心中。
朋友一生一起走那些日子不再有,一句话一辈子一生情一杯九。
朋友不曾孤单过一声朋友你会懂,还有伤还有痛还要走还有我。
Hình đại diện của thành viên
NTN
Thành viên tâm huyết
Thành viên tâm huyết
Bài viết: 491
Ngày tham gia: Thứ 4 05/02/2014 3:43 pm
Đến từ: Đồng Tháp,Việt Nam
Has thanked: 20 times
Been thanked: 7 times
Tiếp xúc:

Re: Hiệu ứng như lao trong vũ trụ

Gửi bài by NTN »

Tôi cũng có chỉnh code của bạn nhưng cũng rất đẹp :P
  1. Private W As Integer
  2. Private H As Integer
  3. Private Type Stars
  4.  x As Double
  5.  y As Integer
  6.  AddX As Integer
  7.  AddY As Integer
  8. End Type
  9. Private Star(1000) As Stars
  10. Private Accelarate As Boolean
  11. Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
  12. Private Sub Command1_Click()
  13. Timer1.Interval = 1
  14. MoveTo = move_forward
  15. Command1.Visible = False
  16. Accelarate = False
  17. WindowState = 2
  18. W = ScaleWidth
  19. H = ScaleHeight
  20.  For i = 1 To 150
  21.   Star(i).x = W / 2
  22.   Star(i).y = H / 2
  23. RandomX
  24.   Randomize
  25.   Star(i).AddX = Int(Rnd * 29) - Int(Rnd * 29)
  26.   If Star(i).AddX = 0 Then GoTo RandomX
  27. RandomY
  28.   Star(i).AddY = Int(Rnd * 19) - Int(Rnd * 19)
  29.   If Star(i).AddY = 0 Then GoTo RandomY
  30.  Next
  31. End Sub
  32. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  33. If KeyCode = vbKeyEscape Then End
  34. End Sub
  35. Private Sub Form_Load()
  36. Me.BorderStyle = 0
  37. Me.DrawWidth = 5
  38. Me.ScaleMode = 3
  39. Me.BackColor = &H80000007
  40. Me.WindowState = 2
  41. End Sub
  42. Private Sub Timer1_Timer()
  43. If Command1.Visible = True Then Exit Sub
  44. For i = 1 To 150
  45.  SetPixel hdc, W / 2, H / 2, &H404040
  46.  Select Case Abs(W / 2 - (Star(i).x))
  47.   Case Is < 20
  48.    col = &H0&
  49.    Size = 1
  50.   Case Is < 100
  51.    col = &H404040
  52.    Size = 1
  53.   Case Is < 122
  54.    col = &H808080
  55.    Size = 2
  56.   Case Is < 155
  57.    col = &HC0C0C0
  58.    Size = 3
  59.   Case Is < 156
  60.    col = &HFFFFFF
  61.    Size = 4
  62.   Case Else
  63.    col = &HFFFFFF
  64.    Size = 5
  65.  End Select
  66.  Select Case Abs(H / 2 - (Star(i).y))
  67.   Case Is < 20
  68.    If Size = 0 Then
  69.     Size = 1
  70.     col = back5
  71.    End If
  72.   Case Is < 80
  73.    If Size = 0 Then
  74.     col = &H404040
  75.     Size = 1
  76.    End If
  77.   Case Is < 150
  78.    If Size < 2 Then
  79.     Size = 2
  80.     col = &H808080
  81.    End If
  82.   Case Is < 200
  83.    If Size < 3 Then
  84.     Size = 3
  85.     col = &HC0C0C0
  86.    End If
  87.   Case Is < 250
  88.    If Size < 4 Then
  89.     Size = 4
  90.     col = &HFFFFFF
  91.    End If
  92.   Case Else
  93.    If Size < 5 Then
  94.     Size = 5
  95.     col = &HFFFFFF
  96.    End If
  97.  End Select
  98. SetPixel hdc, W / 2, H / 2, col
  99. Select Case Size
  100.  Case 1
  101.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  102.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  103.  Case 2
  104.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  105.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&
  106.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  107.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  108.  Case 3
  109.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  110.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&
  111.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y - 1, &H0&
  112.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  113.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  114.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  115.  Case 4
  116.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  117.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&
  118.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y - 1, &H0&
  119.   SetPixel Me.hdc, Star(i).x, Star(i).y - 1, &H0&
  120.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  121.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  122.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  123.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  124.  Case 5
  125.   SetPixel Me.hdc, Star(i).x + a, Star(i).y, &H0&
  126.   SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y, &H0&
  127.   SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y - 1, &H0&
  128.   SetPixel Me.hdc, Star(i).x + a, Star(i).y - 1, &H0&
  129.   SetPixel Me.hdc, Star(i).x + a, Star(i).y - 2, &H0&
  130.   SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y - 2, &H0&
  131.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  132.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  133.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  134.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  135.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 2 + Star(i).AddY, col
  136.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 2 + Star(i).AddY, col
  137. End Select
  138. Star(i).x = Star(i).x + Star(i).AddX
  139. Star(i).y = Star(i).y + Star(i).AddY
  140. Star(i).AddX = Star(i).AddX + Sgn(Star(i).AddX) * (Size / 10)
  141. Star(i).AddY = Star(i).AddY + Sgn(Star(i).AddY) * (Size / 20)
  142. If Accelarate Then
  143.  Star(i).AddX = Star(i).AddX + Sgn(Star(i).AddX) * Size
  144.  Star(i).AddY = Star(i).AddY + Sgn(Star(i).AddY) * Size
  145. End If
  146. If Star(i).x < 0 Or Star(i).x > ScaleWidth Or Star(i).y < 0 Or Star(i).y > ScaleHeight Then
  147.   Star(i).x = W / 5
  148.   Star(i).y = H / 5
  149. RandomX
  150.   Randomize
  151.   Star(i).AddX = Int(Rnd * 219) - Int(Rnd * 219)
  152.   If Star(i).AddX = 0 Then GoTo RandomX
  153. RandomY
  154.   Star(i).AddY = Int(Rnd * 129) - Int(Rnd * 129)
  155.   If Star(i).AddY = 0 Then GoTo RandomY
  156. End If
  157. Next
  158. End Sub
  159.  
Hình đại diện của thành viên
NTN
Thành viên tâm huyết
Thành viên tâm huyết
Bài viết: 491
Ngày tham gia: Thứ 4 05/02/2014 3:43 pm
Đến từ: Đồng Tháp,Việt Nam
Has thanked: 20 times
Been thanked: 7 times
Tiếp xúc:

Re: Hiệu ứng như lao trong vũ trụ

Gửi bài by NTN »

Tạo 1 bức ảnh cũng khá ấn tượng ! :D
  1. Private W As Integer
  2. Private H As Integer
  3. Private Type Stars
  4.  x As Double
  5.  y As Integer
  6.  AddX As Integer
  7.  AddY As Integer
  8. End Type
  9. Private Star(1000) As Stars
  10. Private Accelarate As Boolean
  11. Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
  12. Private Sub Command1_Click()
  13. Timer1.Interval = 1
  14. MoveTo = move_forward
  15. Command1.Visible = False
  16. Accelarate = False
  17. WindowState = 2
  18. W = ScaleWidth
  19. H = ScaleHeight
  20.  For i = 1 To 150
  21.   Star(i).x = W / 2
  22.   Star(i).y = H / 2
  23. RandomX
  24.   Randomize
  25.   Star(i).AddX = Int(Rnd * 29) - Int(Rnd * 29)
  26.   If Star(i).AddX = 0 Then GoTo RandomX
  27. RandomY
  28.   Star(i).AddY = Int(Rnd * 19) - Int(Rnd * 19)
  29.   If Star(i).AddY = 0 Then GoTo RandomY
  30.  Next
  31. End Sub
  32. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  33. If KeyCode = vbKeyEscape Then End
  34. End Sub
  35. Private Sub Form_Load()
  36. Me.BorderStyle = 0
  37. Me.DrawWidth = 5
  38. Me.ScaleMode = 3
  39. Me.BackColor = &H80000007
  40. Me.WindowState = 2
  41. End Sub
  42. Private Sub Timer1_Timer()
  43. If Command1.Visible = True Then Exit Sub
  44. For i = 1 To 150
  45.  SetPixel hdc, W / 2, H / 2, &H404040
  46.  Select Case Abs(W / 2 - (Star(i).x))
  47.   Case Is < 20
  48.    col = &H0&
  49.    Size = 1
  50.   Case Is < 100
  51.    col = &H404040
  52.    Size = 1
  53.   Case Is < 122
  54.    col = &H808080
  55.    Size = 2
  56.   Case Is < 155
  57.    col = &HC0C0C0
  58.    Size = 3
  59.   Case Is < 156
  60.    col = &HFFFFFF
  61.    Size = 4
  62.   Case Else
  63.    col = &HFFFFFF
  64.    Size = 5
  65.  End Select
  66.  Select Case Abs(H / 2 - (Star(i).y))
  67.   Case Is < 20
  68.    If Size = 0 Then
  69.     Size = 1
  70.     col = back5
  71.    End If
  72.   Case Is < 80
  73.    If Size = 0 Then
  74.     col = &H404040
  75.     Size = 1
  76.    End If
  77.   Case Is < 150
  78.    If Size < 2 Then
  79.     Size = 2
  80.     col = &H808080
  81.    End If
  82.   Case Is < 200
  83.    If Size < 3 Then
  84.     Size = 3
  85.     col = &HC0C0C0
  86.    End If
  87.   Case Is < 250
  88.    If Size < 4 Then
  89.     Size = 4
  90.     col = &HFFFFFF
  91.    End If
  92.   Case Else
  93.    If Size < 5 Then
  94.     Size = 5
  95.     col = &HFFFFFF
  96.    End If
  97.  End Select
  98. SetPixel hdc, W / 2, H / 2, col
  99. Select Case Size
  100.  Case 1
  101.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  102.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  103.  Case 2
  104.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  105.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&
  106.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  107.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  108.  Case 3
  109.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  110.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&
  111.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y - 1, &H0&
  112.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  113.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  114.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  115.  Case 4
  116.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  117.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&
  118.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y - 1, &H0&
  119.   SetPixel Me.hdc, Star(i).x, Star(i).y - 1, &H0&
  120.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  121.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  122.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  123.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  124.  Case 5
  125.   SetPixel Me.hdc, Star(i).x + a, Star(i).y, &H0&
  126.   SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y, &H0&
  127.   SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y - 1, &H0&
  128.   SetPixel Me.hdc, Star(i).x + a, Star(i).y - 1, &H0&
  129.   SetPixel Me.hdc, Star(i).x + a, Star(i).y - 2, &H0&
  130.   SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y - 2, &H0&
  131.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  132.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  133.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  134.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  135.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 2 + Star(i).AddY, col
  136.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 2 + Star(i).AddY, col
  137. End Select
  138. Star(i).x = Star(i).x + Star(i).AddX
  139. Star(i).y = Star(i).y + Star(i).AddY
  140. Star(i).AddX = Star(i).AddX + Sgn(Star(i).AddX) * (Size / 10)
  141. Star(i).AddY = Star(i).AddY + Sgn(Star(i).AddY) * (Size / 20)
  142. If Accelarate Then
  143.  Star(i).AddX = Star(i).AddX + Sgn(Star(i).AddX) * Size
  144.  Star(i).AddY = Star(i).AddY + Sgn(Star(i).AddY) * Size
  145. End If
  146. If Star(i).x < 0 Or Star(i).x > ScaleWidth Or Star(i).y < 0 Or Star(i).y > ScaleHeight Then
  147.   Star(i).x = W / 5
  148.   Star(i).y = H / 5
  149. RandomX
  150.   Randomize
  151.   Star(i).AddX = Int(Rnd * 755) - Int(Rnd * 200)
  152.   If Star(i).AddX = 0 Then GoTo RandomX
  153. RandomY
  154.   Star(i).AddY = Int(Rnd * 685) - Int(Rnd * 222)
  155.   If Star(i).AddY = 0 Then GoTo RandomY
  156. End If
  157. Next
  158. End Sub
  159.  
Hình đại diện của thành viên
NTN
Thành viên tâm huyết
Thành viên tâm huyết
Bài viết: 491
Ngày tham gia: Thứ 4 05/02/2014 3:43 pm
Đến từ: Đồng Tháp,Việt Nam
Has thanked: 20 times
Been thanked: 7 times
Tiếp xúc:

Re: Hiệu ứng như lao trong vũ trụ

Gửi bài by NTN »

Cũng dep day !
  1. Private W As Integer
  2. Private H As Integer
  3. Private Type Stars
  4.  x As Double
  5.  y As Integer
  6.  AddX As Integer
  7.  AddY As Integer
  8. End Type
  9. Private Star(1000) As Stars
  10. Private Accelarate As Boolean
  11. Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
  12. Private Sub Command1_Click()
  13. Timer1.Interval = 1
  14. MoveTo = move_forward
  15. Command1.Visible = False
  16. Accelarate = False
  17. WindowState = 2
  18. W = ScaleWidth
  19. H = ScaleHeight
  20.  For i = 1 To 150
  21.   Star(i).x = W / 2
  22.   Star(i).y = H / 2
  23. RandomX
  24.   Randomize
  25.   Star(i).AddX = Int(Rnd * 29) - Int(Rnd * 29)
  26.   If Star(i).AddX = 0 Then GoTo RandomX
  27. RandomY
  28.   Star(i).AddY = Int(Rnd * 19) - Int(Rnd * 19)
  29.   If Star(i).AddY = 0 Then GoTo RandomY
  30.  Next
  31. End Sub
  32. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  33. If KeyCode = vbKeyEscape Then End
  34. End Sub
  35. Private Sub Form_Load()
  36. Me.BorderStyle = 0
  37. Me.DrawWidth = 5
  38. Me.ScaleMode = 3
  39. Me.BackColor = &H80000007
  40. Me.WindowState = 2
  41. End Sub
  42. Private Sub Timer1_Timer()
  43. If Command1.Visible = True Then Exit Sub
  44. For i = 1 To 150
  45.  SetPixel hdc, W / 2, H / 2, &H404040
  46.  Select Case Abs(W / 2 - (Star(i).x))
  47.   Case Is < 20
  48.    col = &H0&
  49.    Size = 1
  50.   Case Is < 100
  51.    col = &H404040
  52.    Size = 1
  53.   Case Is < 122
  54.    col = &H808080
  55.    Size = 2
  56.   Case Is < 155
  57.    col = &HC0C0C0
  58.    Size = 3
  59.   Case Is < 156
  60.    col = &HFFFFFF
  61.    Size = 4
  62.   Case Else
  63.    col = &HFFFFFF
  64.    Size = 5
  65.  End Select
  66.  Select Case Abs(H / 2 - (Star(i).y))
  67.   Case Is < 20
  68.    If Size = 0 Then
  69.     Size = 1
  70.     col = back5
  71.    End If
  72.   Case Is < 80
  73.    If Size = 0 Then
  74.     col = &H404040
  75.     Size = 1
  76.    End If
  77.   Case Is < 150
  78.    If Size < 2 Then
  79.     Size = 2
  80.     col = &H808080
  81.    End If
  82.   Case Is < 200
  83.    If Size < 3 Then
  84.     Size = 3
  85.     col = &HC0C0C0
  86.    End If
  87.   Case Is < 320
  88.    If Size < 4 Then
  89.     Size = 6
  90.     col = &HFFFFFF
  91.    End If
  92.   Case Else
  93.    If Size < 5 Then
  94.     Size = 5
  95.     col = &HFFFFFF
  96.    End If
  97.  End Select
  98. SetPixel hdc, W / 10, H / 5, col
  99. Select Case Size
  100.  Case 1
  101.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  102.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  103.  Case 2
  104.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  105.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&
  106.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  107.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  108.  Case 3
  109.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  110.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&
  111.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y - 1, &H0&
  112.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  113.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  114.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  115.  Case 4
  116.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  117.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&
  118.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y - 1, &H0&
  119.   SetPixel Me.hdc, Star(i).x, Star(i).y - 1, &H0&
  120.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  121.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  122.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  123.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  124.  Case 5
  125.   SetPixel Me.hdc, Star(i).x + a, Star(i).y, &H0&
  126.   SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y, &H0&
  127.   SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y - 1, &H0&
  128.   SetPixel Me.hdc, Star(i).x + a, Star(i).y - 1, &H0&
  129.   SetPixel Me.hdc, Star(i).x + a, Star(i).y - 2, &H0&
  130.   SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y - 2, &H0&
  131.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  132.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  133.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  134.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  135.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 2 + Star(i).AddY, col
  136.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 2 + Star(i).AddY, col
  137. End Select
  138. Star(i).x = Star(i).x + Star(i).AddX
  139. Star(i).y = Star(i).y + Star(i).AddY
  140. Star(i).AddX = Star(i).AddX + Sgn(Star(i).AddX) * (Size / 10)
  141. Star(i).AddY = Star(i).AddY + Sgn(Star(i).AddY) * (Size / 20)
  142. If Accelarate Then
  143.  Star(i).AddX = Star(i).AddX + Sgn(Star(i).AddX) * Size
  144.  Star(i).AddY = Star(i).AddY + Sgn(Star(i).AddY) * Size
  145. End If
  146. If Star(i).x < 0 Or Star(i).x > ScaleWidth Or Star(i).y < 0 Or Star(i).y > ScaleHeight Then
  147.   Star(i).x = W / 5
  148.   Star(i).y = H / 5
  149. RandomX
  150.   Randomize
  151.   Star(i).AddX = Int(Rnd * 755) - Int(Rnd * 200)
  152.   If Star(i).AddX = 0 Then GoTo RandomX
  153. RandomY
  154.   Star(i).AddY = Int(Rnd * 685) - Int(Rnd * 222)
  155.   If Star(i).AddY = 0 Then GoTo RandomY
  156. End If
  157. Next
  158. End Sub
  159.  
Hình đại diện của thành viên
NTN
Thành viên tâm huyết
Thành viên tâm huyết
Bài viết: 491
Ngày tham gia: Thứ 4 05/02/2014 3:43 pm
Đến từ: Đồng Tháp,Việt Nam
Has thanked: 20 times
Been thanked: 7 times
Tiếp xúc:

Re: Hiệu ứng như lao trong vũ trụ

Gửi bài by NTN »

Cửa sổ tuyết !
  1. Private W As Integer
  2. Private H As Integer
  3. Private Type Stars
  4.  x As Double
  5.  y As Integer
  6.  AddX As Integer
  7.  AddY As Integer
  8. End Type
  9. Private Star(1000) As Stars
  10. Private Accelarate As Boolean
  11. Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
  12. Private Sub Command1_Click()
  13. Timer1.Interval = 1
  14. MoveTo = move_forward
  15. Command1.Visible = False
  16. Accelarate = False
  17. WindowState = 2
  18. W = ScaleWidth
  19. H = ScaleHeight
  20.  For i = 1 To 150
  21.   Star(i).x = W / 2
  22.   Star(i).y = H / 2
  23. RandomX
  24.   Randomize
  25.   Star(i).AddX = Int(Rnd * 29) - Int(Rnd * 29)
  26.   If Star(i).AddX = 0 Then GoTo RandomX
  27. RandomY
  28.   Star(i).AddY = Int(Rnd * 19) - Int(Rnd * 19)
  29.   If Star(i).AddY = 0 Then GoTo RandomY
  30.  Next
  31. End Sub
  32. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  33. If KeyCode = vbKeyEscape Then End
  34. End Sub
  35. Private Sub Form_Load()
  36. Me.BorderStyle = 0
  37. Me.DrawWidth = 5
  38. Me.ScaleMode = 3
  39. Me.BackColor = &H80000007
  40. Me.WindowState = 2
  41. End Sub
  42. Private Sub Timer1_Timer()
  43. If Command1.Visible = True Then Exit Sub
  44. For i = 1 To 150
  45.  SetPixel hdc, W / 2, H / 2, &H404040
  46.  Select Case Abs(W / 2 - (Star(i).x))
  47.   Case Is < 20
  48.    col = &H0&
  49.    Size = 1
  50.   Case Is < 100
  51.    col = &H404040
  52.    Size = 1
  53.   Case Is < 122
  54.    col = &H808080
  55.    Size = 2
  56.   Case Is < 155
  57.    col = &HC0C0C0
  58.    Size = 3
  59.   Case Is < 156
  60.    col = &HFFFFFF
  61.    Size = 4
  62.   Case Else
  63.    col = &HFFFFFF
  64.    Size = 5
  65.  End Select
  66.  Select Case Abs(H / 2 - (Star(i).y))
  67.   Case Is < 300
  68.    If Size = 10 Then
  69.     Size = 10
  70.     col = back5
  71.    End If
  72.   Case Is < 100
  73.    If Size = 1 Then
  74.     col = &H404040
  75.     Size = 1
  76.    End If
  77.   Case Is < 150
  78.    If Size < 2 Then
  79.     Size = 2
  80.     col = &H808080
  81.    End If
  82.   Case Is < 200
  83.    If Size < 3 Then
  84.     Size = 3
  85.     col = &HC0C0C0
  86.    End If
  87.   Case Is < 320
  88.    If Size < 4 Then
  89.     Size = 6
  90.     col = &HFFFFFF
  91.    End If
  92.   Case Else
  93.    If Size < 10 Then
  94.     Size = 1
  95.     col = &HFFFFFF
  96.    End If
  97.  End Select
  98. SetPixel hdc, W / 10, H / 5, col
  99. Select Case Size
  100.  Case 1
  101.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  102.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  103.  Case 2
  104.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  105.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&
  106.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  107.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  108.  Case 3
  109.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  110.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&
  111.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y - 1, &H0&
  112.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  113.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  114.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  115.  Case 4
  116.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  117.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&
  118.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y - 1, &H0&
  119.   SetPixel Me.hdc, Star(i).x, Star(i).y - 1, &H0&
  120.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  121.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  122.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  123.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  124.  Case 5
  125.   SetPixel Me.hdc, Star(i).x + a, Star(i).y, &H0&
  126.   SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y, &H0&
  127.   SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y - 1, &H0&
  128.   SetPixel Me.hdc, Star(i).x + a, Star(i).y - 1, &H0&
  129.   SetPixel Me.hdc, Star(i).x + a, Star(i).y - 2, &H0&
  130.   SetPixel Me.hdc, Star(i).x - 1 + a, Star(i).y - 2, &H0&
  131.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  132.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  133.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  134.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  135.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 2 + Star(i).AddY, col
  136.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 2 + Star(i).AddY, col
  137. End Select
  138. Star(i).x = Star(i).x + Star(i).AddX
  139. Star(i).y = Star(i).y + Star(i).AddY
  140. Star(i).AddX = Star(i).AddX + Sgn(Star(i).AddX) * (Size / 10)
  141. Star(i).AddY = Star(i).AddY + Sgn(Star(i).AddY) * (Size / 20)
  142. If Accelarate Then
  143.  Star(i).AddX = Star(i).AddX + Sgn(Star(i).AddX) * Size
  144.  Star(i).AddY = Star(i).AddY + Sgn(Star(i).AddY) * Size
  145. End If
  146. If Star(i).x < 0 Or Star(i).x > ScaleWidth Or Star(i).y < 0 Or Star(i).y > ScaleHeight Then
  147.   Star(i).x = W / 5
  148.   Star(i).y = H / 5
  149. RandomX
  150.   Randomize
  151.   Star(i).AddX = Int(Rnd * 755) - Int(Rnd * 200)
  152.   If Star(i).AddX = 0 Then GoTo RandomX
  153. RandomY
  154.   Star(i).AddY = Int(Rnd * 685) - Int(Rnd * 222)
  155.   If Star(i).AddY = 0 Then GoTo RandomY
  156. End If
  157. Next
  158. End Sub
  159.  
Hình đại diện của thành viên
NTN
Thành viên tâm huyết
Thành viên tâm huyết
Bài viết: 491
Ngày tham gia: Thứ 4 05/02/2014 3:43 pm
Đến từ: Đồng Tháp,Việt Nam
Has thanked: 20 times
Been thanked: 7 times
Tiếp xúc:

Re: Hiệu ứng như lao trong vũ trụ

Gửi bài by NTN »

  1. Private W As Integer
  2. Private H As Integer
  3. Private Type Stars
  4.  x As Double
  5.  y As Integer
  6.  AddX As Integer
  7.  AddY As Integer
  8. End Type
  9. Private Star(1000) As Stars
  10. Private Accelarate As Boolean
  11. Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal crColor As Long) As Long
  12. Private Sub Command1_Click()
  13. Timer1.Interval = 1
  14. MoveTo = move_forward
  15. Command1.Visible = False
  16. Accelarate = False
  17. WindowState = 2
  18. W = ScaleWidth
  19. H = ScaleHeight
  20.  For i = 1 To 150
  21.   Star(i).x = W / 2
  22.   Star(i).y = H / 2
  23. RandomX
  24.   Randomize
  25.   Star(i).AddX = Int(Rnd * 29) - Int(Rnd * 29)
  26.   If Star(i).AddX = 0 Then GoTo RandomX
  27. RandomY
  28.   Star(i).AddY = Int(Rnd * 19) - Int(Rnd * 19)
  29.   If Star(i).AddY = 0 Then GoTo RandomY
  30.  Next
  31. End Sub
  32. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
  33. If KeyCode = vbKeyEscape Then End
  34. End Sub
  35. Private Sub Form_Load()
  36. Me.BorderStyle = 0
  37. Me.DrawWidth = 5
  38. Me.ScaleMode = 3
  39. Me.BackColor = &H80000007
  40. Me.WindowState = 2
  41. End Sub
  42. Private Sub Timer1_Timer()
  43. If Command1.Visible = True Then Exit Sub
  44. For i = 1 To 1
  45.  SetPixel hdc, W / 2, H / 2, &H404040
  46.  Select Case Abs(W / 2 - (Star(i).x))
  47.   Case Is < 10
  48.    col = &H0&
  49.    Size = 1
  50.   Case Is < 100
  51.    col = &H404040
  52.    Size = 1
  53.   Case Is < 122
  54.    col = &H808080
  55.    Size = 2
  56.   Case Is < 155
  57.    col = &HC0C0C0
  58.    Size = 3
  59.   Case Is < 156
  60.    col = &HFFFFFF
  61.    Size = 4
  62.   Case Else
  63.    col = &HFFFFFF
  64.    Size = 5
  65.  End Select
  66.  Select Case Abs(H / 2 - (Star(i).y))
  67.   Case Is < 10
  68.    If Size = 10 Then
  69.     Size = 10
  70.     col = back5
  71.    End If
  72.   Case Is < 15
  73.    If Size = 1 Then
  74.     col = &H404040
  75.     Size = 1
  76.    End If
  77.   Case Is < 55
  78.    If Size < 2 Then
  79.     Size = 2
  80.     col = &H808080
  81.    End If
  82.   Case Is < 6
  83.    If Size < 3 Then
  84.     Size = 3
  85.     col = &HC0C0C0
  86.    End If
  87.   Case Is < 14
  88.    If Size < 4 Then
  89.     Size = 6
  90.     col = &HFFFFFF
  91.    End If
  92.   Case Else
  93.    If Size < 65 Then
  94.     Size = 1
  95.     col = &HFFFFFF
  96.    End If
  97.  End Select
  98. SetPixel hdc, W / 10, H / 5, col
  99. Select Case Size
  100.  Case 1
  101.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  102.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  103.  Case 2
  104.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  105.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&
  106.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  107.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  108.  Case 3
  109.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  110.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y, &H0&
  111.   SetPixel Me.hdc, Star(i).x - 1, Star(i).y - 1, &H0&
  112.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  113.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  114.   SetPixel Me.hdc, Star(i).x - 1 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  115.  Case 4
  116.   SetPixel Me.hdc, Star(i).x, Star(i).y, &H0&
  117.   SetPixel Me.hdc, Star(i).x - 10, Star(i).y, &H0&
  118.   SetPixel Me.hdc, Star(i).x - 10, Star(i).y - 1, &H0&
  119.   SetPixel Me.hdc, Star(i).x, Star(i).y - 1, &H0&
  120.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  121.   SetPixel Me.hdc, Star(i).x - 12 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  122.   SetPixel Me.hdc, Star(i).x - 12 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  123.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  124.  Case 5
  125.   SetPixel Me.hdc, Star(i).x + a, Star(i).y, &H0&
  126.   SetPixel Me.hdc, Star(i).x - 15 + a, Star(i).y, &H0&
  127.   SetPixel Me.hdc, Star(i).x - 15 + a, Star(i).y - 1, &H0&
  128.   SetPixel Me.hdc, Star(i).x + a, Star(i).y - 1, &H0&
  129.   SetPixel Me.hdc, Star(i).x + a, Star(i).y - 2, &H0&
  130.   SetPixel Me.hdc, Star(i).x - 16 + a, Star(i).y - 2, &H0&
  131.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y + Star(i).AddY, col
  132.   SetPixel Me.hdc, Star(i).x - 17 + Star(i).AddX, Star(i).y + Star(i).AddY, col
  133.   SetPixel Me.hdc, Star(i).x - 17 + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  134.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 1 + Star(i).AddY, col
  135.   SetPixel Me.hdc, Star(i).x + Star(i).AddX, Star(i).y - 2 + Star(i).AddY, col
  136.   SetPixel Me.hdc, Star(i).x - 19 + Star(i).AddX, Star(i).y - 2 + Star(i).AddY, col
  137. End Select
  138. Star(i).x = Star(i).x + Star(i).AddX
  139. Star(i).y = Star(i).y + Star(i).AddY
  140. Star(i).AddX = Star(i).AddX + Sgn(Star(i).AddX) * (Size / 10)
  141. Star(i).AddY = Star(i).AddY + Sgn(Star(i).AddY) * (Size / 20)
  142. If Accelarate Then
  143.  Star(i).AddX = Star(i).AddX + Sgn(Star(i).AddX) * Size
  144.  Star(i).AddY = Star(i).AddY + Sgn(Star(i).AddY) * Size
  145. End If
  146. If Star(i).x < 0 Or Star(i).x > ScaleWidth Or Star(i).y < 0 Or Star(i).y > ScaleHeight Then
  147.   Star(i).x = W / 5
  148.   Star(i).y = H / 5
  149. RandomX
  150.   Randomize
  151.   Star(i).AddX = Int(Rnd * 755) - Int(Rnd * 200)
  152.   If Star(i).AddX = 0 Then GoTo RandomX
  153. RandomY
  154.   Star(i).AddY = Int(Rnd * 685) - Int(Rnd * 222)
  155.   If Star(i).AddY = 0 Then GoTo RandomY
  156. End If
  157. Next
  158. End Sub
  159.  
Đăng trả lời

Quay về