Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic (http://www.programmingforums.org/forum18.html)
-   -   Screen Saver (sort of ...) (http://www.programmingforums.org/showthread.php?t=14552)

Megabyte Nov 21st, 2007 8:42 PM

Screen Saver (sort of ...)
 
Well, technically not a screen saver (or not right now). But our current project is to make one set of the lines from the 'mystify' screen saver on Windows.

:

Option Explicit

Private Sub cmdStart_Click()

Dim sngX As Single
Dim sngY As Single
Dim sngX2 As Single
Dim sngY2 As Single
Dim sngColors As Single
Dim sngDelay As Single
Dim intChangeX As Integer
Dim intChangeY As Integer
Dim intChangeX2 As Integer
Dim intChangeY2 As Integer

intChangeX = 1
intChangeY = 1
intChangeX2 = 2
intChangeY2 = 2

Do
    sngX = sngX + intChangeX
    sngY = sngY + intChangeY
    Line (sngX, sngY)-(10000, 8000), sngColors
 
    sngDelay = 0
    Do
        sngDelay = sngDelay + 1
    Loop Until sngDelay = 1000
 
    Line (sngX, sngY)-(10000, 8000), vbBlack
    If sngY >= Me.Height - 380 Then
        intChangeY = -1
        sngColors = vbGreen
    End If
    If sngX >= Me.Width - 380 Then
        intChangeX = -1
        sngColors = vbYellow
    End If
    If sngY <= 0 Then
        intChangeY = 1
        sngColors = vbRed
    End If
    If sngX <= 0 Then
        intChangeX = 1
        sngColors = &H80FF&
    End If
 
    Line (sngX, sngY)-(5000, 4000), sngColors
 
    sngDelay = 0
    Do
        sngDelay = sngDelay + 1
    Loop Until sngDelay = 1000
 
    Line (sngX, sngY)-(5000, 4000), vbBlack
    If sngY >= Me.Height - 380 Then
        intChangeY = -1
        sngColors = vbGreen
    End If
    If sngX >= Me.Width - 380 Then
        intChangeX = -1
        sngColors = vbYellow
    End If
    If sngY <= 0 Then
        intChangeY = 1
        sngColors = vbRed
    End If
    If sngX <= 0 Then
        intChangeX = 1
        sngColors = &H80FF&
    End If
 
    sngX2 = sngX2 + intChangeX2
    sngY2 = sngY2 + intChangeY2
 
    Line (sngX2, sngY2)-(10000, 8000), sngColors
 
    sngDelay = 0
    Do
        sngDelay = sngDelay + 1
    Loop Until sngDelay = 1000
 
    Line (sngX2, sngY2)-(10000, 8000), vbBlack
    If sngY2 >= Me.Height - 380 Then
        intChangeY2 = -1
        sngColors = vbGreen
    End If
    If sngX2 >= Me.Width - 380 Then
        intChangeX2 = -1
        sngColors = vbYellow
    End If
    If sngY2 <= 0 Then
        intChangeY2 = 1
        sngColors = vbRed
    End If
    If sngX2 <= 0 Then
        intChangeX2 = 1
        sngColors = &H80FF&
    End If
 
    Line (sngX2, sngY2)-(5000, 4000), sngColors
 
    sngDelay = 0
    Do
        sngDelay = sngDelay + 1
    Loop Until sngDelay = 1000
 
    Line (sngX2, sngY2)-(5000, 4000), vbBlack
    If sngY2 >= Me.Height - 380 Then
        intChangeY2 = -1
        sngColors = vbGreen
    End If
    If sngX2 >= Me.Width - 380 Then
        intChangeX2 = -1
        sngColors = vbYellow
    End If
    If sngY2 <= 0 Then
        intChangeY2 = 1
        sngColors = vbRed
    End If
    If sngX2 <= 0 Then
        intChangeX2 = 1
        sngColors = &H80FF&
    End If
 
Loop Until sngX > Me.Width

End Sub

Private Sub Form_Load()

Me.WindowState = 2

End Sub


At this point, pretty much all of it works, except 2 of the points don't move.

http://img159.imageshack.us/img159/3596/ssrt6.jpg
The points circled in red continue to remain stationary.

What needs to be added and/or changed in my code to do so?

Saw someone else just asked a question similar .. Possibly from my class (or another period) since it all looks familiar in that code. Heh. :p

Megabyte Nov 29th, 2007 5:27 PM

Re: Screen Saver (sort of ...)
 
Is anyone able to provide some help for this?

Wizard1988 Nov 29th, 2007 5:30 PM

Re: Screen Saver (sort of ...)
 
One thing you can try is changing different values in the code and observing how they change the drawing. From there you can modify the code to fit your needs.

Megabyte Nov 29th, 2007 5:50 PM

Re: Screen Saver (sort of ...)
 
I don't think I need a specific value. I believe I need something similar to the sngX and the sngY where the (10000, 8000) and (5000, 4000) values are.
So I believe I would need something like and sngXChange and sngYChange, along with sngXChange2 and sngYChange2 in those places.

I don't really know what the numbers they need to equal have to be or how to implement them. I tried the other day but it screwed up my program.

If I don't have the correct idea please let me know, and any other tips, hints, or whatever to help me finish are appreciated.


All times are GMT -5. The time now is 3:22 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC