### Author Topic: Bonkers Symphony Number 37  (Read 168 times)

#### B+

• Sr. Member
• Posts: 436
##### Bonkers Symphony Number 37
« on: 21. April 2017, 23:00:26 »
Code: [Select]
`' Bonkers Symphony Number 37.bas  SmallBASIC 0.12.9 [B+=MGA] 2017-04-21def rand(lo, hi) = (rnd * (hi - lo + 1)) \ 1 + lo def rdir = iff(rnd < .5, -1, 1)gravity = 3'ballsbR = 10n = 80 speed = 12dim x(n), y(n), a(n), c(n), rr(n), gg(n), bb(n), rd(n)for i = 1 to n  x(i) = rand(xmax/2-10, xmax/2+10)  y(i) = rand(-200, 0)  rd(i) = rand(3, 20)  a(i) = pi/2 + pi/90 * rdir  rr(i) = rand(60, 100)  gg(i) = rand(60, 100)  bb(i) = rand(60, 100)next'pinspR = 25maxrow = 7nP = maxrow * (maxrow + 1) * .5pxo = xmax / (maxrow + 1) 'pin space along xpyo = ymax / (maxrow + 1) 'pin spacing along ydim px(nP), py(nP)for row = 1 to maxrow  for col = 1 TO row    pidx +=1    px(pidx) = pxo*col+(maxrow - row) * .5*pxo    py(pidx) = pyo*row  nextnextclrMode = 1while 1  k = inkey  if asc(k) = 32 then clrMode *= -1  if clrMode < 0 then cls  'draw pins  for i = 1 to nP    for r = pR to 1 step -1      color rgb(r/pR*255,r/pR*255, r/pR*255)      circle px(i), py(i), r filled    next  next   'calc collsions  for i = 1 to n    for j = 1 to nP      if sqr((x(i)-px(j))^2 + (y(i)-py(j))^2) < rd(i) + pR then          a(i) = atan2(y(i)-py(j), x(i)-px(j))          color 0          circle px(j), py(j), pR filled          sound 120 + py(j)/ ymax * 5000, px(j) / xmax * 55          exit for      end if    next    for j = i + 1 to n      if j <> i and c(j) <> 1 then        if sqr((x(i)-x(j))^2 + (y(i)-y(j))^2) < rd(i) + rd(j) then          a(i) = atan2(y(i)-y(j), x(i)-x(j))          a(j) = atan2(y(j)-y(i), x(j)-x(i))          c(i) = 1 : c(j) = 1          exit for        fi      fi    next        'update balls    dx = cos(a(i)) * speed    dy = sin(a(i)) * speed + gravity    a(i) = atan2(dy, dx)    x(i) = x(i) + cos(a(i)) * speed    y(i) = y(i) + sin(a(i)) * speed        if x(i) < rd(i) or x(i) > xmax + rd(i) or y(i) > ymax + rd(i) then       x(i) = rand(xmax/2-10, xmax/2+10)      y(i) = rand(-250, -bR)      a(i) = pi/2 + pi/90 * rdir    fi    if a(i) > 2 * pi then a(i) = a(i) - 2 * pi    if a(i) < 0 then a(i) = a(i) + 2 * pi      for r = rd(i) to 1 step -1      color rgb(255-rr(i)-150*r/rd(i), 255-gg(i)-150*r/rd(i), 255-bb(i)-150*r/rd(i))      circle x(i), y(i), r filled    next    c(i) = 0  next  showpage  delay 10wend`

#### ZXDunny

• Full Member
• Posts: 134
##### Re: Bonkers Symphony Number 37
« Reply #1 on: 22. April 2017, 00:11:20 »

#### B+

• Sr. Member
• Posts: 436
##### Re: Bonkers Symphony Number 37
« Reply #2 on: 22. April 2017, 01:05:30 »
Yeah, sort of where I got the idea along with previous Bonkers work but I don't hear anything from yourtube???
« Last Edit: 22. April 2017, 01:11:25 by B+ »

#### ZXDunny

• Full Member
• Posts: 134
##### Re: Bonkers Symphony Number 37
« Reply #3 on: 22. April 2017, 21:18:51 »
Yeah, sort of where I got the idea along with previous Bonkers work but I don't hear anything from yourtube???

Am I supposed to beep or something when the particles collide?