Code: Select all
' waterfall effect by neil
Screenres 800, 600, 32
Dim As Integer x(800), y(800), x2(800), y2(800), r(800), a(800)
Dim As Double v(800)
Dim As String key
For i As Integer = 0 To 799
x(i) = Rnd * 800 : y(i) = Rnd * 600
x2(i) = x(i) : y2(i) = y(i)
r(i) = 100 + Rnd * 155 : a(i) = 0
Next
Do
key = Inkey
Screenlock
Cls
For i As Integer = 0 To 799
' Move water down
y(i) = y(i) + 2
' Reset if water reaches bottom
If y(i) > 599 Then
x(i) = Rnd * 800 : y(i) = Rnd * 10
End If
' Update water position
x2(i) = x(i) + r(i) * Cos(a(i))
y2(i) = y(i) + r(i) * Sin(a(i))
' Draw line between current and previous position
Line(x(i), y(i)) - (y2(i), x2(i)), Rgb(0, 0, 255)
' Increase angle for next frame
a(i) = a(i) + 0.05
' Add velocity to make waterfall effect
r(i) = r(i) + v(i)
v(i) = v(i) + 0.1
Next
ScreenUnlock
Sleep 10,1
Loop Until (key = Chr(27)) Or (key = Chr(255) & "k")
End