• Vui lòng đọc nội qui diễn đàn để tránh bị xóa bài viết
  • Tìm kiếm trước khi đặt câu hỏi

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...
QuangHoa
Guru
Guru
Bài viết: 542
Ngày tham gia: T.Năm 27/03/2008 9:02 am
Đến từ: Quê hương Đại tướng Võ Nguyên Giáp
Been thanked: 5 time
Liên hệ:

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

Gửi bàigửi bởi QuangHoa » T.Hai 09/06/2008 8:51 am

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 hế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 < 80
  51.    col = &H404040
  52.    Size = 1
  53.   Case Is < 150
  54.    col = &H808080
  55.    Size = 2
  56.   Case Is < 200
  57.    col = &HC0C0C0
  58.    Size = 3
  59.   Case Is < 250
  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 / 5)
  141. Star(i).AddY = Star(i).AddY + Sgn(Star(i).AddY) * (Size / 5)
  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 / 2
  148.   Star(i).y = H / 2
  149. RandomX:
  150.   Randomize
  151.   Star(i).AddX = Int(Rnd * 29) - Int(Rnd * 29)
  152.   If Star(i).AddX = 0 Then GoTo RandomX
  153. RandomY:
  154.   Star(i).AddY = Int(Rnd * 19) - Int(Rnd * 19)
  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 người dùng
NTN
Thành viên tâm huyết
Thành viên tâm huyết
Bài viết: 472
Ngày tham gia: T.Tư 05/02/2014 3:43 pm
Đến từ: Cao Lãnh, Đồng Tháp,Việt Nam
Has thanked: 19 time
Been thanked: 7 time
Liên hệ:

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

Gửi bàigửi bởi NTN » T.Hai 28/07/2014 7:37 pm

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.  
  160.  

Hình đại diện của người dùng
NTN
Thành viên tâm huyết
Thành viên tâm huyết
Bài viết: 472
Ngày tham gia: T.Tư 05/02/2014 3:43 pm
Đến từ: Cao Lãnh, Đồng Tháp,Việt Nam
Has thanked: 19 time
Been thanked: 7 time
Liên hệ:

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

Gửi bàigửi bởi NTN » T.Hai 28/07/2014 7:40 pm

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.  
  160.  

Hình đại diện của người dùng
NTN
Thành viên tâm huyết
Thành viên tâm huyết
Bài viết: 472
Ngày tham gia: T.Tư 05/02/2014 3:43 pm
Đến từ: Cao Lãnh, Đồng Tháp,Việt Nam
Has thanked: 19 time
Been thanked: 7 time
Liên hệ:

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

Gửi bàigửi bởi NTN » T.Hai 28/07/2014 7:41 pm

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.  
  160.  

Hình đại diện của người dùng
NTN
Thành viên tâm huyết
Thành viên tâm huyết
Bài viết: 472
Ngày tham gia: T.Tư 05/02/2014 3:43 pm
Đến từ: Cao Lãnh, Đồng Tháp,Việt Nam
Has thanked: 19 time
Been thanked: 7 time
Liên hệ:

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

Gửi bàigửi bởi NTN » T.Hai 28/07/2014 7:43 pm

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.  
  160.  

Hình đại diện của người dùng
NTN
Thành viên tâm huyết
Thành viên tâm huyết
Bài viết: 472
Ngày tham gia: T.Tư 05/02/2014 3:43 pm
Đến từ: Cao Lãnh, Đồng Tháp,Việt Nam
Has thanked: 19 time
Been thanked: 7 time
Liên hệ:

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

Gửi bàigửi bởi NTN » T.Hai 28/07/2014 7:45 pm

  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.  
  160.  


Quay về “[VB] Âm thanh và Đồ họa”

Đang trực tuyến

Đang xem chuyên mục này: Không có thành viên nào trực tuyến.0 khách