Dark Bit Factory & Gravity

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

Title: 3D Starfield
Post by: bikemadness on May 06, 2026
Done to death, but this is my first.

I finally figuured something out.

Code: [Select]
star=200
dim r(star)
dim x(star)
dim y(star)
dim l(star)
dim d(star)
dim s(star)
dim m(star)

for a=1 to star
r(a)=int(ran(360))*(pi/180)
l(a)=int(ran(400))+160
d(a)=ran(1)-int(ran(2)) rem height
s(a)=ran(2)+2 rem couples with l(a) s(a)/l(a)
m(a)=.005
next a

x=320
y=256

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

for a=1 to star
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 star
r(a)=r(a)+m(a)
if m(a)>360 m(a)=0
next a

for a=1 to star
dot x(a),y(a)
next a

until (1=0)