2D Parallax Stars by Richard Davey12th Sep 2003 12:58
|
---|
Summary I was fed-up seeing so many slow and jittery 2D starfields done in DarkBasic that I did my own. This is a proper parallax, depth shaded starfield and in my tests I was seeing 500 Description ========================================================== Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ` 2D Parallax Starfield ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ` By Rich Davey (rich@fatal-design.com) ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ` Music listened to while coding this ` Madonna (Ray of Light) ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ` Note: ` ` On my graphics card (GeForce 256 Pro) I can get a consistent 75 fps ` with 500 stars on-screen. You can push this up to around 800 stars ` if you change the x array into 3 seperate arrays, instead of having ` 1 array with 3 elements. sync rate 0 sync on hide mouse n=500 dim x(n,3) for i=1 to n x(i,1)=rnd(639)+1 x(i,2)=rnd(479)+ 1 x(i,3)=rnd(9)+1 next i do cls 0 for i=1 to n x(i,1)=x(i,1)-x(i,3) if x(i,1)<=1 x(i,1)=640 x(i,2)=rnd(479)+1 endif col=x(i,3)*30 ink rgb(col,col,col),1 dot x(i,1),x(i,2) next i sync loop |