Advertisement
ASP_Volume3 Graphics #61005

Moving StarField Form BG (3D Version)

This is a really cool form effect, it looks like a starfield moving from the middle of the screen out at you, it kind of looks like the Windows screen saver. This is not originally my code, but i like it so much that i have made a better version of it. You can change the speed and color of the field. This is an update of my last submission (http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=40900&lngWId=1). Enjoy

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
<p><font face="Verdana"><b><u><small><small>Moving StarField Form BG (3D
Version)<br>
</small></small></u><small><small>by Adam Lane</small></small><br>
<br>
</b><small><small>1) Create a form and a timer<br>
2) Form1 and Timer1<br>
3) Copy this code into your form</small></small></font><small><small><font face="Courier New"><small><small><br>
<br>
</small></small></font></small></small><font face="Courier New"><small><small><small><small>Dim X(50), Y(50), xSpeed(50), ySpeed(50) As Integer<br>
<br>
Private Sub Form_Load()<br>
&nbsp;&nbsp;&nbsp; Dim i As Integer<br>
&nbsp;&nbsp;&nbsp; Timer1.Interval = 4<br>
&nbsp;&nbsp;&nbsp; Form1.BackColor = vbBlack<br>
&nbsp;&nbsp;&nbsp; Form1.ForeColor = vbBlack<br>
&nbsp;&nbsp;&nbsp; Form1.FillColor = vbBlack<br>
&nbsp;&nbsp;&nbsp; For i = 0 To 49<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X(i) = -1<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Y(i) = -1<br>
&nbsp;&nbsp;&nbsp; Next i<br>
&nbsp;&nbsp;&nbsp; Randomize<br>
&nbsp;&nbsp;&nbsp; Timer1.Enabled = True<br>
End Sub<br>
<br>
Private Sub Timer1_Timer()<br>
&nbsp;&nbsp;&nbsp; Dim i As Integer<br>
&nbsp;&nbsp;&nbsp; For i = 0 To 49<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PSet (X(i), Y(i)), &amp;H0&amp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If X(i) &lt; 0 Or X(i) > Form1.ScaleWidth Or Y(i) &lt; 0 Or Y(i) > Form1.ScaleHeight Then<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X(i) = Form1.ScaleWidth \ 2<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Y(i) = Form1.ScaleHeight \ 2<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xSpeed(i) = Int(Rnd(1) * 200) - 100<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ySpeed(i) = Int(Rnd(1) * 200) - 100<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; End If<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; X(i) = X(i) + xSpeed(i)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Y(i) = Y(i) + ySpeed(i)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PSet (X(i), Y(i)), &amp;HFFFFFF<br>
&nbsp;&nbsp;&nbsp; Next i<br>
End Sub</small></small></small></small></font></p>
Original Comments (3)
Recovered from Wayback Machine