by Adam Lane (3 Submissions)
Category: Graphics
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (3 Votes)
This is a really cool ScreenSaver, it looks like a bunch of lines following eachother and bouncing off the sides of your screen. It is a clone of the windows screensaver. You can change the speed and color of the lines. Enjoy
Bouncing
Lines ScreenSaver
by
Adam Lane
1) Create a
borderless
form and a timer
2) Form1 and Timer1
3) Copy this code into your form
Dim x(4), Y(4), xSpeed(4), ySpeed(4), Trails As Integer
Private Sub Form_Load()
Form1.WindowState = vbMaximized
Form1.BackColor = vbBlack
Form1.ForeColor = vbBlack
Form1.FillColor = vbBlack
Timer1.Interval = 1
For i = 0 To 3
x(i) = Form1.ScaleWidth \ 2
Y(i) = Form1.ScaleHeight \ 2
Next i
xSpeed(0) = -150: xSpeed(2) = -150
xSpeed(1) = 70: xSpeed(3) = 70
ySpeed(0) = -105: ySpeed(2) = -105
ySpeed(1) = 90: ySpeed(3) = 90
Trails = 50
End Sub
Private Sub Timer1_Timer()
Dim z As Integer
If Trails > 0 Then
Trails = Trails - 1
z = 1
Else
z = 3
End If
For i = 0 To z
x(i) = x(i) + xSpeed(i)
Y(i) = Y(i) + ySpeed(i)
If x(i) < 0 Or x(i) > Form1.ScaleWidth Then xSpeed(i) =
-xSpeed(i)
If Y(i) < 0 Or Y(i) > Form1.ScaleHeight Then ySpeed(i) =
-ySpeed(i)
Next i
Line (x(0), Y(0))-(x(1), Y(1)), vbBlue
Line (x(2), Y(2))-(x(3), Y(3)), vbBlack
DoEvents
End Sub