Dalam Postingan ini saya akan memberikan cara bagaimana membuat animasi kerlap-kerlip seperti bintang kecil yang bergerak, Penasaran?????
Berikut ini tutorialnya:
- Buka Program VB 6.0
- pada form tambahkan komponen Timer dan ganti nilai intervalnya menjadi 1 pada properties
- selanjutnya klik 2 kali pada form anda dan hapus semua teks yang ada jendela kode lalu copy listing berikut ini:
Dim X(100), Y(100), Z(100) As Integer
Dim tmpX(100), tmpY(100), tmpZ(100) As Integer
Dim K As Integer
Dim Zoom As Integer
Dim Speed As Integer
Dim I, Radius, StarColor
Private Sub Form_Activate()
Speed = -1
K = 2038
Zoom = 256
Timer1.Interval = 1
For I = 0 To 100
X(I) = Int(Rnd * 1024) - 512
Y(I) = Int(Rnd * 1024) - 512
Z(I) = Int(Rnd * 512) - 256
Next I
End Sub
Private Sub Timer1_Timer()
For I = 0 To 100
Circle (tmpX(I), tmpY(I)), 10, BackColor
Z(I) = Z(I) + Speed
If Z(I) > 255 Then Z(I) = -255
If Z(I) < -255 Then Z(I) = 255
tmpZ(I) = Z(I) + Zoom
tmpX(I) = (X(I) * K / tmpZ(I)) + (Me.Width / 2)
tmpY(I) = (Y(I) * K / tmpZ(I)) + (Me.Height / 2)
Radius = 1
StarColor = 256 - Z(I)
Circle (tmpX(I), tmpY(I)), 10, RGB(StarColor, StarColor, StarColor)
Next I
End Sub
Dim tmpX(100), tmpY(100), tmpZ(100) As Integer
Dim K As Integer
Dim Zoom As Integer
Dim Speed As Integer
Dim I, Radius, StarColor
Private Sub Form_Activate()
Speed = -1
K = 2038
Zoom = 256
Timer1.Interval = 1
For I = 0 To 100
X(I) = Int(Rnd * 1024) - 512
Y(I) = Int(Rnd * 1024) - 512
Z(I) = Int(Rnd * 512) - 256
Next I
End Sub
Private Sub Timer1_Timer()
For I = 0 To 100
Circle (tmpX(I), tmpY(I)), 10, BackColor
Z(I) = Z(I) + Speed
If Z(I) > 255 Then Z(I) = -255
If Z(I) < -255 Then Z(I) = 255
tmpZ(I) = Z(I) + Zoom
tmpX(I) = (X(I) * K / tmpZ(I)) + (Me.Width / 2)
tmpY(I) = (Y(I) * K / tmpZ(I)) + (Me.Height / 2)
Radius = 1
StarColor = 256 - Z(I)
Circle (tmpX(I), tmpY(I)), 10, RGB(StarColor, StarColor, StarColor)
Next I
End Sub
- setelah dicopy silahkan paste di jendela listing lalu coba jalankan atau tekan F5
Selamat bekerja dan semoga sukses
Bisa dicoba ni gan buat referensi, ditunggu kunjungan baliknya
ReplyDeletehttp://carakuvb6.blogspot.com