mostly accurate 2d gravity simulation I made in 295 chars
(295 chars)
p={}for i=0,20do add(p,{rnd(127),rnd(127),0,0,1})end::_::cls()for i in all(p)do for j in all(p)do x=j[1]-i[1]y=j[2]-i[2]d=x^2+y^2f=0.03*j[5]/d if d<5and d!=0then for k=3,5do i[k]=(i[k]+j[k])/2end i[5]*=2del(p,j)else i[3]+=x*f i[4]+=y*f end end i[1]+=i[3]i[2]+=i[4]pset(i[1],i[2])end flip()goto _ |
[Please log in to post a comment]