08-25-2023, 01:47 PM
Black hole collision B256 in micro(A)
Code: (Select All)
'black hole collision B256
var x,y,xspeed,yspeed,r,n,colision
x=160 : y = 180 : xspeed = 2 : yspeed = -1 : r=2 : n = 401
var xx[n] , yy[n] , xxspeed[n] , yyspeed[n] ,dist[n]
var dx[n] , dy[n], xac[n], yac[n+1], gravity[n], crash[n]
var p,s,px,py,t : colision = 0
p=1
while p < n
xx[p]=rand(600)
yy[p]=rand(600)
p=p+1
wend
s=1
while s < n
xxspeed[s]=rand(2)-1
yyspeed[s]=rand(2)-1
s=s+1
wend
px=300 : py=300
circle px,py,5
label loop
fcolor 190,190,190
rect 0,0,800,600
t=1
WHILE t < n
dist[t] = ((xx[t]-px)^2 + (yy[t]-py)^2)^(1/2)
gravity[t] = (r/dist[t])^2
dx[t] = xx[t]-px
dy[t] = yy[t]-py
xac[t]= (dx[t]/dist[t]) * gravity[t]
yac[t]= (dy[t]/dist[t]) * gravity[t]
if crash[t]=0 : xxspeed[t] = xxspeed[t]*0.999-xac[t] : endif
if crash[t]=0 : yyspeed[t] = yyspeed[t]*0.999-yac[t] : endif
if crash[t]=0 : xx[t] = xx[t] + xxspeed[t] : endif
if crash[t]=0 : yy[t] = yy[t] + yyspeed[t] : endif
If dist[t] < r & crash[t]=0
r=r+8/r^2
colision = colision + 1
crash[t]=1
EndIf
print 10,10,"Colisions =": print 120,10,colision
fcolor 180,140,100 : circle xx[t], yy[t],2 ' rand(3)
t=t+2
WEND
circle px,py,r
swap
goto loop
micro(A)developer
http://basic4us.epizy.com/forum/index.php
http://basic4us.epizy.com/forum/index.php