Dark Bit Factory & Gravity

PROGRAMMING => Other languages => Yabasic => Topic started by: bikemadness on May 08, 2026

Title: 3D Ring Of Planets
Post by: bikemadness on May 08, 2026
Shows colours and sorting.

Code: [Select]
point=20
dim r(point)
dim x(point)
dim y(point)
dim l(point)
dim d(point)
dim s(point)
dim m(point)
dim R(point)
dim G(point)
dim B(point)
dim size(point)
dim order$(point)
ang=360/point

for a=1 to point
r(a)=a*ang*(pi/180)
l(a)=500 rem int(ran(300))+200
s(a)=2
d(a)=-.1
m(a)=.005
R(a)=ran(256)
G(a)=ran(256)
B(a)=ran(256)
next a

x=320
y=256

open window 640,512
repeat
setdrawbuf vm
vm=1-vm
setdispbuf vm
clear window

for a=1 to point
x(a)=cos(r(a))/(sin(r(a))+s(a))*l(a)+x
y(a)=d(a)/(sin(r(a))+s(a))*l(a)+y
next a

for a=1 to point
r(a)=r(a)+m(a)
if m(a)>360 m(a)=0
next a

for a=1 to point
order$(a)=str$(size(a))
next a

for k=1 to point-1
for j=1 to point-k

if order$(j)>order$(j+1) then

temp=r(j)
r(j)=r(j+1)
r(j+1)=temp

temp=x(j)
x(j)=x(j+1)
x(j+1)=temp

temp=y(j)
y(j)=y(j+1)
y(j+1)=temp

temp=l(j)
l(j)=l(j+1)
l(j+1)=temp

temp=d(j)
d(j)=d(j+1)
d(j+1)=temp

temp=s(j)
s(j)=s(j+1)
s(j+1)=temp

temp=m(j)
m(j)=m(j+1)
m(j+1)=temp

temp=R(j)
R(j)=R(j+1)
R(j+1)=temp

temp=G(j)
G(j)=G(j+1)
G(j+1)=temp

temp=B(j)
B(j)=B(j+1)
B(j+1)=temp

temp=size(j)
size(j)=size(j+1)
size(j+1)=temp

temp$=order$(j)
order$(j)=order$(j+1)
order$(j+1)=temp$

endif

next j
next k

for a=1 to point
size(a)=15*(10-(y(a)/27))
setrgb 1,R(a),G(a),B(a)
fill circle x(a),y(a),size(a)
setrgb 1,256,256,256
circle x(a),y(a),size(a)
next a

until (1=0)