BlitzCoder Essentials
•
Home Page
•
About BlitzCoder
•
Contributors
•
Terms of Use
•
Email Us
Main Areas
•
BlitzCoder Chat
•
Discussions
•
Articles/Tutorials
•
Code Database
•
Link Database
•
Showcase Area
•
Worklogs
•
Competitions
Special Areas
•
Undocumented
Other Blitz Sites
•
Blitz Basic Home
•
Blitz Showcase
•
BlitzPlay Library
Forum Login
Username:
Password:
•
Register Now!
BlitzCoder Code Archives Page
Main Codes Page
"3D Starfield"
, by stompy
Create a cool starfield.
Only uses integers and has depth colouring.
Code
Const SCREEN_WIDTH = 640 Const SCREEN_HEIGHT = 480 Const KEY_QUIT = 1 Global starsN = 500 Dim starsI(starsN) Dim starsX(starsN) Dim starsY(starsN) Dim starsZ(starsN) For x = 0 To starsN starsX(x) = Rnd(6400) starsY(x) = Rnd(4800) Next Graphics SCREEN_WIDTH , SCREEN_HEIGHT , 0 , 1 SetBuffer BackBuffer() Repeat If KeyDown(KEY_QUIT) FlushKeys End End If For x = 0 To starsN diffsX = (starsX(x) - 3200) diffsY = (starsY(x) - 2400) If Abs(diffsX) < 20 Then diffsX = 20 If Abs(diffsY) < 20 Then diffsY = 20 tx = starsx(x) ty = starsy(x) starsX(x) = tx + (DiffsX/20) starsY(x) = ty + (DiffsY/20) tc = Abs(diffsx) + Abs(diffsy) If tc > 2600 Then Color 255,255,255 If tc < 2600 And tc > 2000 Then Color 225,225,225 If tc < 2000 And tc > 1500 Then Color 200,200,200 If tc < 1500 And tc > 1250 Then Color 175,175,175 If tc < 1250 And tc > 1000 Then Color 150,150,150 If tc < 1000 And tc > 700 Then Color 125,125,125 If tc < 700 And tc > 500 Then Color 100,100,100 If tc < 500 And tc > 100 Then Color 75,75,75 If tc < 100 Then Color 50,50,50 If starsX(x) < 0 Or starsX(x) > 6400 Or starsY(x) < 0 Or starsY(x) > 4800 starsX(x) = 3200 + (Rnd(1600)) - 800 starsY(x) = 2400 + (Rnd(1600)) - 800 Else Plot starsX(x)/10, starsY(x)/10 EndIf Next Flip Cls Forever
Copyright(c) 2000-2004, BlitzCoder. All Rights Reserved.
Code software created by Krylar's Kreations