Visual Basic Raindrops

Subscribers:
593
Published on ● Video Link: https://www.youtube.com/watch?v=Bf0dKXotmYc



Duration: 0:25
41 views
0


WAY oversimplified demonstration of Visual Basics constants and how they apply to real life, and one two dimensional and quick and very ugly implementation of gravity's effects without demonstrating acceleration.

Option Explicit

Private Const PI As Double = 3.14159 ' A perfect circle.
Private Const SPEEDOFLIGHT As Double = 186000 ' miles per second
Private Const GRAVITY As Double = 9.8 ' meters per second

Private m_colDots As New Collection

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, _
x As Single, y As Single)
If (Button = vbLeftButton) Then
m_colDots.Add x & "," & y
Me.PSet (x, y), &HFFFFFF * Rnd(&HFFFFFF)
End If
End Sub

Private Sub tmrMain_Timer()
Dim x As Single, y As Single
Dim sCur As Variant
Me.Refresh
Dim oNC As New Collection
For Each sCur In m_colDots
x = CSng(Trim(Split(sCur, ",")(0)))
y = CSng(Trim(Split(sCur, ",")(1))) + GRAVITY
Me.PSet (x, y), &HFFFFFF * Rnd(&HFFFFFF)
oNC.Add x & "," & y
Next sCur
Set m_colDots = oNC
End Sub