x_width=1024 y_width=768 depth=32 set display mode x_width,y_width,depth hide mouse sync on max=100 dim x#(max) dim y#(max) dim x1#(max) dim y1#(max) dim a#(max) dim b#(max) dim radius#(max) dim mass#(max) dim move(max) dim colour(max) for t=1 to max read x#(t),y#(t),a#(t),b#(t),radius#(t),mass#(t),colour(t) move(t)=1 next t vadjust#=200.0 stop_orbit=0 quit=0 while not quit if not stop_orbit cls make_button(10,y_width-50,100,y_width-25,"F1 Setup") sync gosub run_orbit endif if (stop_orbit=1) ink rgb(255,255,255),0 cls make_button(10,20,190,45,"F2 Create Object") make_button(200,20,290,45,"F3 Run") gosub show_planets sync key=0 while not key if keystate(60) ink 0,0 cls x=250 y=100 window1() gosub show_planets ink rgb(255,255,255),0 set cursor 10,20 print "Set Size:" set cursor 1,45 print " Hold mouse button" print " drag to resize" print " planet" print " Object ";count radius#=scale(x,y) mass#=radius# cls window1() gosub show_planets ink rgb(255,255,255),0 set cursor 10,20 print "Colour:" print " Object ";count colour=set_colour(180,20,radius#) cls gosub show_planets ink rgb(255,255,255),0 set cursor 10,20 print "Set Position:" set cursor 1,45 print " Use mouse to" print " position planet," print " then click" print " Object ";count gosub locate_planet cls gosub show_planets ink rgb(255,255,255),0 set cursor 10,20 print "Set Vector:" set cursor 1,45 print " Use mouse to" print " set initial" print " velocity." print " Click to save" print " Object ";count gosub set_vector x#(count)=x y#(count)=y a#(count)=a# b#(count)=b# radius#(count)=radius# mass#(count)=mass# move(count)=1 colour(count)=colour count=count+1 max=max+1 key=1 endif if keystate(61) stop_orbit=0 key=1 endif endwhile endif endwhile end function set_colour(x,y,radius#) for i=0 to 7 for j=0 to 7 ink rgb(128,i*32,j*32),0 box i*10+x,j*10+y,i*10+x+9,j*10+y+9 next j next i sync set=0 while (mouseclick()>0) endwhile while not set if (mouseclick()>0) if (mousex()>x) and (mousex()<80+x) and (mousey()>y) and (mousey()<80+y) i=int((mousex()-x)/10) j=int((mousey()-y)/10) set=1 endif endif endwhile colour=rgb(128,i*32,j*32) endfunction colour function scale(x,y) position mouse x,y show mouse set=0 value=1 click=0 ink rgb(128,128,128),0 circle x,y,value while (mouseclick()>0) endwhile while not set if mouseclick() click=1 value1=value value=abs(mousex()-x) if value<1 then value=1 if value>50 then value=50 ink 0,0 circle x,y,value1 ink rgb (128,128,128),0 circle x,y,value endif if ((click) and (mouseclick()=0)) set=1 endif sync endwhile endfunction value function make_button(x,y,width,height,name$) ink rgb(128,128,128),0 box x,y,width,height ink rgb(255,255,255),0 set cursor x+5,y+5 print name$ endfunction function window1() ink rgb(255,255,255),0 box 0,0,350,250 ink rgb(128,128,128),0 box 2,2,348,248 ink 0,0 box 150,3,347,247 endfunction show_planets: for i=1 to max ink colour(i),0 circle x#(i),y#(i),radius#(i) ink rgb(255,255,255),0 line x#(i),y#(i),x#(i)+a#(i)*vadjust#,y#(i)+b#(i)*vadjust# next i return locate_planet: while (mouseclick()>0) endwhile x1=x_width/2 y1=y_width/2 set=0 position mouse x1,y1 while not set x=mousex() y=mousey() ink 0,0 circle x1,y1,radius# ink colour,0 circle x,y,radius# x1=x y1=y if mouseclick() set=1 endif sync endwhile return set_vector: a#=0.0 b#=0.0 set=0 while (mouseclick()>0) endwhile while not set ink 0,0 circle x,y,radius# line x,y,x+a#,y+b# a#=mousex()-x b#=mousey()-y ink colour,0 circle x,y,radius# ink rgb(255,255,255),0 line x,y,x+a#,y+b# if (mouseclick()>0) set=1 a#=a#/vadjust# b#=b#/vadjust# endif sync endwhile return run_orbit: while not stop_orbit for p=1 to max for i=1 to max if (i<>p) if (move(p)=1) and (move(i)=1) deltax#=x#(i)-x#(p) deltay#=y#(i)-y#(p) distance#=sqrt(deltax#^2+deltay#^2) if (distance#-radius#(p)) > radius#(i) attract#=mass#(i)/distance#^2 xv#=attract#*deltax#/distance# yv#=attract#*deltay#/distance# a#(p)=a#(p)+xv# b#(p)=b#(p)+yv# else a#(p)=a#(p)+a#(i)*mass#(i)/mass#(p) b#(p)=b#(p)+b#(i)*mass#(i)/mass#(p) mass#(p)=mass#(p)+mass#(i) radius#(p)=radius#(p)+sqrt(radius#(i)) mass#(i)=0 move(i)=0 endif endif endif next i next p xav#=x#(1) yav#=y#(1) for p=1 to max x#(p)=x#(p)+a#(p) y#(p)=y#(p)+b#(p) ink 0,0 circle int(x1#(p)),int(y1#(p)),radius#(p) ink colour(p),0 if mass#(p)>0 circle int(x#(p)),int(y#(p)),radius#(p) endif x1#(p)=x#(p) y1#(p)=y#(p) next p if (keystate(59)) stop_orbit=1 endif sync endwhile max=0 count=1 return end DATA 512,384,0,-.008,10,40,16776960 DATA 300,384,0,.35,5,1,255 DATA 290,384,0,.7,1,.1,255