8 xgrav% = 0: ygrav% = 10: size% = 15: timestep% = 20: maxradius% = 30:goto 21 10 cls 15 input "Enter n: ", size% 17 input "Enter time step (normal - 20): ", timestep% 19 input "Enter max radius: ", maxradius% 21 w% = screenwidth(0): h% = screenheight(0) 22 hhh = 1.0 24 constx% = xgrav% * timestep% * timestep% / 2000 26 consty% = ygrav% * timestep% * timestep% / 2000 30 dim posx%(size%) 40 dim posy%(size%) 50 dim prevposx%(size%) 60 dim prevposy%(size%) 70 dim radius%(size%) 100 for i% = 0 to size% - 1 110 posx%(i%) = i% * 5 + 50 120 posy%(i%) = i% * 5 + 50 130 radius%(i%) = abs(mod(rnd(0), maxradius%)) 140 prevposx%(i%) = posx%(i%) - 1 150 prevposy%(i%) = posy%(i%) - 1 160 next i% 190 cls 195 print t%: t% = milliseconds(0) 200 for i% = 0 to size% - 1 300 drawarc posx%(i%) - radius%(i%), posy%(i%) - radius%(i%), 2 * radius%(i%), 2 * radius%(i%), 0, 360 400 next i% 500 repaint 600 for i% = 0 to size% - 1 700 tempx% = posx%(i%) 800 tempy% = posy%(i%) 900 posx%(i%) = posx%(i%) + posx%(i%) - prevposx%(i%) + constx% 1000 posy%(i%) = posy%(i%) + posy%(i%) - prevposy%(i%) + consty% 1100 prevposx%(i%) = tempx% 1200 prevposy%(i%) = tempy% 1300 next i% 1400 if up(0)<>0 then xgrav% = 0: ygrav% = -10 1500 if down(0)<>0 then xgrav% = 0: ygrav% = 10 1600 if right(0)<>0 then xgrav% = 10: ygrav% = 0 1700 if left(0)<>0 then xgrav% = -10: ygrav% = 0 1720 if gamea(0)<>0 then xgrav% = -7: ygrav% = -7 1740 if gameb(0)<>0 then xgrav% = 7: ygrav% = -7 1760 if gamec(0)<>0 then xgrav% = -7: ygrav% = 7 1780 if gamed(0)<>0 then xgrav% = 7: ygrav% = 7 1790 if fire(0)<>0 then xgrav% = 0: ygrav% = 0 1795 if inkey(0)=48 then goto 10 1800 constx% = xgrav% * timestep% * timestep% / 2000 1900 consty% = ygrav% * timestep% * timestep% / 2000 3000 for i% = 0 to size% - 1 3100 for j% = i% + 1 to size% - 1 3150 if j% = size% then goto 4000 3200 tempx% = posx%(j%) - posx%(i%) 3250 tempy% = posy%(j%) - posy%(i%) 3300 dist% = sqr(tempx% * tempx% + tempy% * tempy%) 3317 if dist% = 0 then posx%(i%) = posx%(i%) + 1: posy%(i%) = posy%(i%) + 1: goto 3200 3350 length% = radius%(i%) + radius%(j%) 3400 if dist% < length% then gosub 3500 3450 goto 4000 3500 movex% = tempx% * (dist% - length%) / (dist% * 2) 3550 movey% = tempy% * (dist% - length%) / (dist% * 2) 3600 posx%(i%) = posx%(i%) + movex% 3650 posx%(j%) = posx%(j%) - movex% 3700 posy%(i%) = posy%(i%) + movey% 3750 posy%(j%) = posy%(j%) - movey% 3900 return 4000 next j% 4100 if posx%(i%) + radius%(i%) > w% then posx%(i%) = w% - radius%(i%) 4150 if posx%(i%) - radius%(i%) < 0 then posx%(i%) = radius%(i%) 4200 if posy%(i%) + radius%(i%) > h% then posy%(i%) = h% - radius%(i%) 4250 if posy%(i%) - radius%(i%) < 0 then posy%(i%) = radius%(i%) 4300 next i% 5000 t% = milliseconds(0) - t%: sleep timestep% - t% 5100 goto 190 30000 print "OK" 30005 repaint 30010 goto 30000