Double post - but since this is technically an update I think it's alright.
The solar system now has fractal moons, for want of a better expression. For example: let's say you build a solar system with 3 planets. Each of those planets will have 3 moons - and each of those moons will have 3 moons - and so on.
In theory this could go on forever, I think. You can set the number of planets and the number of moons now at the start. Typing "0" for the number of moons results in only planets being generated (as opposed to just having a sun there). So typing "2" for the number of moons will generate the sun, planets, moons and moons of moons.
If a planet (or moon) has a size of less than 2, a dot is drawn on screen where it should be.
Rem Project: star systems
Rem Created: 03/01/2009 20:06:12
Rem ***** Main Source File *****
sync on : sync rate 120
`makes it easier to calculate the observable space
`set camera fov 0,90
sync
input "How many planets do you want in your solar system? ",pppp
sync
dec pppp
sync
input "How many levels of moons do you want? ",llll
text 0,60,"Switch orbit circles on/off with the spacebar. Press a key to continue."
sync
wait key
text 0,80,"Press any key to start building star field."
sync
wait key
cls
sync
box 0,0,0,0,rgb(0,0,0),rgb(0,0,0),rgb(0,0,0),rgb(0,0,0)
stars=screen width()/4
for t=0 to stars
dot rnd(screen width()),rnd(screen height()),rgb(180,180,180)
sync
next t
get image 1,0,0,screen width(),screen height()
`switch autocam off, so we can bloody well iterate
autocam off
`position the camera above the origin and point it downward
position camera 0,0,173,0 : point camera 0,0,0,0
global objcount=0
global string$=""
global circles=0
global level_limit=llll
global iter=0
`make a sun
make object sphere 1,20 `the sun
`make object sphere 2,5 `the planet
inc objcount
inc objcount
h=360
make object plain objcount,h,(h/4)*3
position object objcount,0,-50,0 : texture object objcount,1 : point object objcount,0,0,0
#constant planets=pppp `one less than the true number, since 0 is a place too
type templatetype
size as float
orbit as float
endtype
DIM template(planets) as templatetype
for t=0 to planets
randomize t
p=rnd(60)
template(t).size=p
p=0
while p<=20
p=rnd(100)
template(t).orbit=p
endwhile
next t
remstart
template(0).size=10 : template(0).orbit=40
template(1).size=5 : template(1).orbit=60
template(2).size=3 : template(2).orbit=75
template(3).size=6 : template(3).orbit=90
remend
type planettype
size as float
orbit as float `orbit size, that is
number as integer `the object number
level as integer `the level of planet. 0=stars, 1=planets, 2=moons
parent as integer `the object number of its parent
parentindex as integer `the entry within the "planet" array held by its parent
endtype
DIM planet(0) as planettype
planet(0).size=20.0
planet(0).orbit=0
planet(0).number=1
planet(0).level=0
iter=0
position object 1,0,0,0
i=iter
remstart
for t=0 to planets
make_planet(t,1)
next t
remend
remstart
for s=0 to array count(planet(0))
if planet(s).parent=1
for t=0 to planets
make_planet(t,s)
next t
endif
next s
remend
for s=0 to level_limit
if s=0
for t=0 to planets
make_planet(t,1)
next t
endif
if s>0
for d=0 to array count(planet(0))
if planet(d).level=s
for t=0 to planets
make_planet(t,planet(d).number)
next t
endif
next d
endif
next s
color object 1,rgb(255,255,0)
`place the sun at the origin
dots=1
do
`orbit(50,0.5,2,0,0)
for t=0 to array count(planet(0))
if planet(t).parent>0 then orbit(planet(t).orbit,(100-planet(t).orbit)*0.01,planet(t).number,object position x(planet(t).parent),object position z(planet(t).parent))
if circles=1
`circle screen width()/2,screen height()/2,(planet(t).orbit/132)*screen width()/2
if planet(t).parent>0 then circle object screen x(planet(t).parent),object screen y(planet(t).parent),(planet(t).orbit/132)*screen width()/2
endif
if dots=1
if object size(planet(t).number)<2 then dot object screen x(planet(t).number),object screen y(planet(t).number)
endif
next t
text 0,0,string$
if spacekey()=1 and spacedown=0
if circles=1 then circles=0 else circles=1
spacedown=1
endif
if spacekey()=0 then spacedown=0
sync
loop
`-----------------------------------------------------------------------------------------------------------------------
function orbit(siz,speed#,num,x,z)
position object num,x,0,z
yrotate object num,object angle y(num)+speed#
move object num,siz
endfunction
`-----------------------------------------------------------------------------------------------------------------------
function make_planet(num,par)
inc objcount
array insert at bottom planet(0)
top=array count(planet(0))
p=0
for q=0 to array count(planet(0))
if par=planet(q).number then p=q
next q
planet(top).parentindex=p
planet(top).size=int(template(num).size/100*planet(p).size)
planet(top).orbit=int(template(num).orbit/20*planet(p).size)
planet(top).level=planet(p).level+1
make object sphere objcount,planet(top).size
planet(top).number=objcount
planet(top).parent=par
position object objcount,object position x(par),0,object position z(par)
yrotate object objcount,rnd(360)
move object objcount,planet(top).orbit
endfunction
`-----------------------------------------------------------------------------------------------------------------------
function count_objects()
n=0
for t=1 to 20
if object exist(t)=1 then inc n
next t
string$=str$(n)
endfunction
Secretary of Unknowable Knowledge for the Rock/Dink administration '08