Author Topic: 3D Starfield  (Read 95 times)

0 Members and 1 Guest are viewing this topic.

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 318
  • Karma: 25
  • Hard players don't go home.
    • View Profile
3D Starfield
« 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)
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17412
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: 3D Starfield
« Reply #1 on: May 08, 2026 »
Well done, that's great  :)

This is rotating around the Z axis, if you move dots whilst also rotating it gives a nice variation of the effect.
This one is doing a Y rotation whilst moving the plots around:

https://www.youtube.com/watch?v=onO0gKbtGuU


Shockwave ^ Codigos
Challenge Trophies Won:

Offline bikemadness

  • Amiga 1200
  • ****
  • Posts: 318
  • Karma: 25
  • Hard players don't go home.
    • View Profile
Re: 3D Starfield
« Reply #2 on: May 08, 2026 »
Thanks. Its taken me years to get head around it.

The first one I saw was on the PS2 demo disc.

The code just blew me away.

I still have a number of those disks.
Have a Yahappy day.
I don't know what is wrong with the world - but I know how to fix it.