article

Bouncing Lines ScreenSaver

Email
Submitted on: 1/29/2015 11:19:00 AM
By: Adam Lane (from psc cd)  
Level: Intermediate
User Rating: By 3 Users
Compatibility: VB 5.0, VB 6.0
Views: 1931
 
     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


Other 2 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Intermediate category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.