Originally posted by Lewis999 in the snippets, just updated , in now faster and animated to a 3d starfield
set display mode 1680,1050,32
sync off
sync rate 30
global points =70 : global w = 1680 : global h = 1050 : dim p(points,1)
dim di(points):dim dy(points):dim regions(w,h) :dim sz(points)
ln = 0
for p = 1 to points : p(p,0) = rnd(w) : p(p,1) = rnd(h)
di(p)=rnd(1355)
dy(p)=1+rnd(4)
make object cube p,10
sz(p)=rnd(500)
hide object p
NEXT p
set camera range 20,4000
MAKE MEMBLOCK FROM BITMAP 1,0
color backdrop 0
backdrop off
position camera 0,0,-100
point camera 0,0,0
``````````````````````````````````````
do
for y = 1 to h-1
yo=y*w*4
yo=yo+16
for x = 1 to w-2
c_distance0 = w*h
for p = 0 to points-2 step 3
q=p(p,0)-x
v=p(p,1)-y
p_distance = q*q+v*v
if p_distance < c_distance0
c_point0 = p
c_distance0 = p_distance
endif
q=p(p+1,0)-x
v=p(p+1,1)-y
p_distance = q*q+v*v
if p_distance < c_distance0
c_point0 = p
c_distance0 = p_distance
endif
q=p(p+2,0)-x
v=p(p+2,1)-y
p_distance = q*q+v*v
if p_distance < c_distance0
c_point0 = p
c_distance0 = p_distance
endif
next p
if yo<7056000
c_point1=c_point0
if memblock byte(1,yo-4)<>c_point0 then c_point1=90
if memblock byte(1,yo-6720)<>c_point0 then c_point1=c_point1+50
write memblock byte 1,yo,c_point0
write memblock byte 1,yo+1,c_point1
write memblock byte 1,yo+2,c_point0*1.2
inc yo,4
endif
next x
next y
make bitmap from memblock 0,1
gosub mover
sync
``gosub saver
loop
mover:
for f=1 to points
zz=di(f)
zz=zz-dy(f)
if zz<0 then zz=2500+rnd(500):sz(f)=rnd(1500)
di(f)=zz
xxx=sz(f)*sin(zz)
yyy=sz(f)*cos(zz)
position object f,xxx,yyy,zz
x=object screen x(f)
y=object screen y(f)
p(f,0)=x
p(f,1)=y
next f
return
remstart
saver:
sv$="000000"
inc fra:sv1$=str$(fra):sv$=sv$+sv1$
sv$=right$(sv$,5)
fil$="I:\frames15\":fil$=fil$+sv$+".jpg"
get image 1000,0,0,1680,1050,1
save image fil$,1000
if fra>3000 then end
return
remend