Quick Search for:  in language:    
draws,moving,starfield,form,with,simple,graph
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Visual Basic Stats

 Code: 3,014,970. lines
 Jobs: 119. postings

 How to support the site

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for Visual Basic.
Click here to see a screenshot of this code!Xp Frames , Xp List Box And XpTextBox (updated!)
By ali s on 7/2

(Screen Shot)

Click here to see a screenshot of this code!Excel Into a webpage
By Bill Donahue on 7/2

(Screen Shot)

Unroll2 - Update
By Cyber Chris on 7/2


MultilinePWD
By Cyber Chris on 7/2


Click here to see a screenshot of this code!Song/Poem Assistant
By Peter Rowan on 7/2

(Screen Shot)

Click here to see a screenshot of this code!GPA Cal
By KBM-00 on 7/2

(Screen Shot)

Click here to see a screenshot of this code!Connection Via the Telephone line.No internet or cable.Just the telephone line
By Nass ClickMan on 7/2

(Screen Shot)

DBTool
By Make Strömberg on 7/2


Click here to see a screenshot of this code!MSChart Simple Example
By Sebastian Pereira on 7/2

(Screen Shot)

Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Draw a moving starfield on a form

Print
Email
 

Submitted on: 5/28/1998
By: Theo Kandiliotis  
Level: Not Given
User Rating: By 101 Users
Compatibility:VB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0

Users have accessed this code 19004 times.
 
 
     It draws a moving starfield on a form with simple VB graphics methods and a timer control.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

'**************************************
' Name: Draw a moving starfield on a for
'     m
' Description:It draws a moving starfiel
'     d on a form with simple VB graphics meth
'     ods and a timer control.
' By: Theo Kandiliotis
'
'This code is copyrighted and has' limited warranties.Please see http://w
'     ww.Planet-Source-Code.com/vb/scripts/Sho
'     wCode.asp?txtCodeId=906&lngWId;=1'for details.'**************************************

How To draw a moving starfield
This example shows how To design a moving star field ,the standard animated background used in most space shoot'em up games.You know,the one that asteroids of all kinds of sizes zip by With various speeds,creating a 3D effect.Here we go: 
1.Create a Timer control. 2.Make these settings through the Properties Window:
Form1.WindowStart = 2
    Form1.Backcolor = &H00000000;& (that's black)
        Timer1.Interval = 1
        3.The algorythm is kinda complicated To explain in spoken words,so I'll leave it up to you to figer out what's going on. 
        Dim X(50), Y(50), pace(50), size(50) As Integer
Private Sub Form_Activate()

Randomize For I = 1 To 50 x1 = Int(Form1.Width * Rnd) y1 = Int(Form1.Height * Rnd) pace1 = Int(500 - (Int(Rnd * 499))) size1 = 16 * Rnd X(I) = x1 Y(I) = y1 pace(I) = pace1 size(I) = size1 Next
End Sub
Private Sub Timer1_Timer()
For I = 1 To 50 Circle (X(I), Y(I)), size(I), BackColor Y(I) = Y(I) + pace(I) If Y(I) >= Form1.Height Then Y(I) = 0: X(I) = Int(Form1.Width * Rnd) Circle (X(I), Y(I)), size(I) Next
End Sub


Other 3 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Not Given 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
5/11/1999 6:47:00 PM:Dan
The background has to be white because 
the stars are black.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/13/1999 11:29:00 AM:MN Karthik
Nice piece of graphics. Hope you create 
more such graphics to help beginners 
like us.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/22/1999 9:38:00 AM:tommy
is there any way to get the stars to be 
white, and the back color black, 
looking more like a space shot?
I'm 
reffering to the: Draw a moving 
starfield on a form 
   Submitted on: 5/28/98
       By: Theo Kandiliotis 
thanks
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/25/1999 11:42:00 AM:Keir
For that person that wanted to make 
white on black, simply change 
"backcolor" in the timer statement to 
the code for white, and set your form 
background to black.  Also i think this 
code needs a "CLS" at the beginning of 
the timer code.  at least it does if 
you are doing white on black
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
6/19/1999 1:19:00 AM:Mr.Man
There's an easier way to make the stars 
white and the back black... You just 
make the Frm's ForeColor = white!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
7/24/1999 1:20:00 PM:Theo Floyd
This is really cool, it works 
well
thanks!!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/4/1999 9:10:00 AM:Steve
i can't get this to work, can someone 
send me the exe file of it so i know 
what it should look like?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/18/1999 7:27:00 AM:Michel Rutten
Stars dropping down? I hope I never 
have to witness that in real life... 
:-)
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/3/1999 2:24:00 PM:HammerHead
Pretty cool application.  Keir is 
right, though, you need a CLS at the 
beginning of the timer to clear the 
screen between each run.  Otherwise it 
creates a pretty frightening (and 
sickening) effect.
I wonder if I 
could do something similar to the 
Matrix with this...
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/24/1999 6:50:00 PM:tenya
I would like to know how to create grid 
coordinate in VB5, then when the user 
click on it the point will appear with 
the point coordinate(x,y)........I hope 
if there is anyone know about it can 
help me...pleaseeeeeeeeee...thanks a lot
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/26/1999 8:07:00 PM:Owen
Hey this is ausome but I was 
just
wondering if there was a way 
to
stop the "stars" from eating 
away
pictures and other objects. THANZ!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/26/1999 8:08:00 PM:Owen
Hey this is awsome but I was 
just
wondering if there was a way 
to
stop the "stars" from eating 
away
pictures and other objects, THANZ!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/26/1999 8:09:00 PM:Owen
oops!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
2/21/2000 10:39:13 PM:Billy Bob
Owen, set the form's autoredraw to 
true. That will stop the stars from 
eating away at the form's graphics.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
8/16/2000 8:31:24 AM:Toby Gunston
Very cool for such a small amount of 
code!
Nice work
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
9/26/2000 7:22:41 PM:Jimmy
Do you know that you can change that 
setting, that appeared as bubbles?  
haha, I figured it out, it is cool.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Visual Basic Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.