graphsize 600,600

x=160

y=180

xspeed=2

yspeed=-1

r=2

n=400

dim x(n+1)

dim y(n+1)

dim xspeed(n+1)

dim yspeed(n+1)

dim dist(n+1)

dim dx(n+1)

dim dy(n+1)

dim xac(n+1)

dim yac(n+1)

dim gravity(n+1)

dim crash(n+1)

colision = 0

for p = 1 to n

x[p]=rand*600

y[p]=rand*600

next p

for s = 1 to n

xspeed[s]=rand*2-1

yspeed[s]=rand*2-1

next s

px=300

py=300

circle px,py,5

fastgraphics

loop:

clg

for t = 1 to n

dist[t]=((x[t]-px)^2 + (y[t]-py)^2)^(1/2)

gravity[t] = (r/dist[t])^2

dx[t]=x[t]-px

dy[t]=y[t]-py

xac[t]= (dx[t]/dist[t])*gravity[t]

yac[t]= (dy[t]/dist[t])*gravity[t]

if crash[t]=0 then xspeed[t]=xspeed[t]*.999-xac[t]

if crash[t]=0 then yspeed[t]=yspeed[t]*.999-yac[t]

if crash[t]=0 then x[t]=x[t]+xspeed[t]

if crash[t]=0 then y[t]=y[t]+yspeed[t]

if dist[t] < r and crash[t]=0 then

r=r+8/r^2

colision = colision+1

crash[t]=1

end if

text 10,10,"Colisions="+colision

circle x[t],y[t],2

next t

circle px,py,r

refresh

goto loop

## No comments:

## Post a Comment