VB icon

a 3d starfield!!!!!!!

Submitted on: 1/24/2015 10:46:00 PM
By: A Kubacki (from psc cd)  
Level: Beginner
User Rating: By 8 Users
Compatibility: VB 5.0, VB 6.0
Views: 921
     3d starfield
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
' Name: a 3d starfield!!!!!!!
' Description:3d starfield
' By: A Kubacki (from psc cd)
' Returns:stars!!!
' Assumes:all you need is a timer control, and a back background for the form
' Side Effects:extreme obsessiong with putting this on every platform possible, calculators, etc...

Dim X(1000) As Integer
Dim Y(1000) As Integer
Dim z(1000) As Integer
Dim xv(1000) As Long
Dim yv(1000) As Long
Dim sss As Long
Dim numstarz As Integer
Dim colora As Long
Dim i, j, k, m As Integer
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyEscape Then
End If
End Sub
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 1
numstarz = 250
Form1.Enabled = True
End Sub
Private Sub init()
For i = 1 To numstarz
X(i) = Rnd() * 1000 - 500
Y(i) = Rnd() * 1000 - 500
z(i) = 1 + Rnd() * 256
Next i
End Sub
Private Sub drawptz()
Dim asdf As Integer
sss = 40 * ScaleWidth / 1000
For k = 1 To numstarz
xv(k) = X(k) * 3 * sss / ((z(k)))
yv(k) = Y(k) * 3 * sss / ((z(k)))
Next k
For j = 1 To numstarz
z(j) = z(j) - 1
If z(j) < 40 Then
z(j) = 200 + Rnd() * 40
End If
Next j
For i = 1 To numstarz
asdf = 256 - z(i)
colora = RGB(asdf, asdf, asdf)
PSet (xv(i) + ScaleWidth / 2, yv(i) + ScaleHeight / 2), colora
Next i
End Sub
Private Sub Timer1_Timer()
 Form1.Enabled = True
 Timer1.Enabled = True
For m = 1 To 10
Next m
End Sub

Other 1 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 code (in the Beginner category)?
(The code 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 code, please click here instead.)

To post feedback, first please login.