Nightron | Community Of Freedom

Would you like to react to this message? Create an account in a few clicks or log in to continue.

    Buat Form Bersalju

    avatar
    Bft'Vian
    Administrator
    Administrator


    Jumlah posting : 162
    Points : 506
    Reputation : 0
    Join date : 17.09.10
    Age : 28
    Lokasi : Bandung

     Buat Form Bersalju Empty Buat Form Bersalju

    Post by Bft'Vian Mon Feb 14, 2011 8:51 am

    Langsung Aja Cekicrott........

    -Tambahkan Timer 1 di Form Anda Dengan Interval 500

    -Tambahkan Langi 1 Module dengan Name Module1

    Isi Code Berikut Pada Module
    Code:
    Option Explicit

    Type xparticle
    x As Integer
    y As Integer
    oldX As Integer
    oldY As Integer
    iStopped As Integer
    End Type

    Global Const kecepatan_salju = 400
    Global Const ukuran_salju = 1
    Global snow(0 To kecepatan_salju) As xparticle

    Tambahkan Code Di Bawah Pada Form

    Code:
    option Explicit
    Dim jalan As Boolean

    Private Sub Form_Load()
    ScaleMode = vbPixels
    DrawWidth = ukuran_salju
    BackColor = vbBlack

    Dim i As Integer

    For i = 0 To kecepatan_salju
    snow(i).x = CInt(Int(ScaleWidth * Rnd))
    snow(i).y = CInt(Int(ScaleHeight * Rnd))
    Next

    jalan = True
    Timer1.Enabled = True

    Const sTEXT = "TeRRen.Jr"
    ForeColor = vbRed
    FontSize = 20
    CurrentX = ScaleWidth / 2 - TextWidth(sTEXT) / 2
    CurrentY = ScaleHeight / 2 - TextHeight(sTEXT) / 2 - 5
    Print sTEXT

    Const sText2 = "aLdy"
    CurrentX = ScaleWidth / 2 - TextWidth(sText2) / 2
    CurrentY = ScaleHeight / 2 + TextHeight(sText2) + 2
    Print sText2

    ForeColor = vbWhite
    End Sub

    Sub DrawSnow()
    Dim i As Integer
    Dim newX As Integer
    Dim newY As Integer

    Timer1.Enabled = False

    Do While jalan
    For i = 0 To kecepatan_salju
    PSet (snow(i).oldX, snow(i).oldY), vbBlack
    PSet (snow(i).x, snow(i).y)
    Next i

    For i = 0 To kecepatan_salju
    snow(i).oldX = snow(i).x
    snow(i).oldY = snow(i).y
    newX = snow(i).x + Int(2 * Rnd)
    newX = newX - Int(2 * Rnd)

    newY = snow(i).y + 1

    If Point(newX, newY) = vbBlack Then
    snow(i).y = newY
    snow(i).x = newX
    Else
    If snow(i).iStopped = 10 Then
    If Point(snow(i).x + 1, snow(i).y + 1) = vbBlack Then
    snow(i).x = snow(i).x + 1
    snow(i).y = snow(i).y + 1
    snow(i).iStopped = 0
    ElseIf Me.Point(snow(i).x - 1, snow(i).y + 1) = vbBlack Then
    snow(i).x = snow(i).x - 1
    snow(i).y = snow(i).y + 1
    snow(i).iStopped = 0
    Else
    NewParticle (i)
    End If
    Else
    snow(i).iStopped = snow(i).iStopped + 1
    End If
    End If
    Next i
    DoEvents
    Loop
    End Sub

    Sub NewParticle(i As Integer)
    snow(i).x = CInt(Int(ScaleWidth * Rnd))
    snow(i).y = 0
    snow(i).oldX = 0
    snow(i).oldY = 0
    snow(i).iStopped = 0
    End Sub

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    jalan = False
    End Sub

    Private Sub Timer1_Timer()
    DrawSnow
    End Sub

    [size="4"]Jika Post Berguna ++[/size]

      Waktu sekarang Mon May 13, 2024 8:00 pm