Author Topic: Bonkers Symphony No. 37  (Read 4509 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Bonkers Symphony No. 37
« on: September 30, 2018, 06:03:59 pm »
"It doesn't alter the fact that you are all bonkers, nuts, potty, reactionary and mental."

While in the land of Potty, B+ comes up with this:
Code: QB64: [Select]
  1. _TITLE "Bonkers Synphony #37  by bplus, press spacebar for different view"
  2.  
  3.  
  4. ' Bonkers Symphony no 37.bas for QB64 fork (B+=MGA) trans 2017-09-15
  5. ' from: Bonkers Symphony Number 37.bas  SmallBASIC 0.12.8 [B+=MGA] 2017-04-21
  6. CONST xmax = 800
  7. CONST ymax = 600
  8.  
  9. SCREEN _NEWIMAGE(xmax, ymax, 32)
  10. gravity = 3
  11.  
  12. 'balls
  13. bR = 10
  14. n = 12
  15. speed = 12
  16. DIM x(n), y(n), a(n), c(n), rr(n), gg(n), bb(n), rd(n)
  17. FOR i = 1 TO n
  18.     x(i) = rand(xmax / 2 - 10, xmax / 2 + 10)
  19.     y(i) = rand(-200, 0)
  20.     rd(i) = rand(3, 20)
  21.     a(i) = _PI(.5) + _PI(1 / 90) * rdir
  22.     rr(i) = rand(60, 100)
  23.     gg(i) = rand(60, 100)
  24.     bb(i) = rand(60, 100)
  25.  
  26. 'pins
  27. pR = 25
  28. maxrow = 7
  29. nP = maxrow * (maxrow + 1) * .5
  30. pxo = xmax / (maxrow + 1) 'pin space along x
  31. pyo = ymax / (maxrow + 1) 'pin spacing along y
  32. DIM px(nP), py(nP)
  33. FOR row = 1 TO maxrow
  34.     FOR col = 1 TO row
  35.         pidx = pidx + 1
  36.         px(pidx) = pxo * col + (maxrow - row) * .5 * pxo
  37.         py(pidx) = pyo * row
  38.     NEXT
  39.  
  40. clrMode = 1
  41.  
  42.     IF _KEYHIT = 32 THEN clrMode = clrMode * -1
  43.     IF clrMode < 0 THEN CLS
  44.  
  45.     'draw pins
  46.     FOR i = 1 TO nP
  47.         FOR r = pR TO 1 STEP -1
  48.             COLOR _RGB(r / pR * 255, r / pR * 255, r / pR * 255)
  49.             fcirc px(i), py(i), r
  50.         NEXT
  51.     NEXT
  52.  
  53.     'calc collsions
  54.     FOR i = 1 TO n
  55.         FOR j = 1 TO nP
  56.             IF SQR((x(i) - px(j)) ^ 2 + (y(i) - py(j)) ^ 2) < rd(i) + pR THEN
  57.                 a(i) = _ATAN2(y(i) - py(j), x(i) - px(j))
  58.                 COLOR _RGB(0, 0, 0)
  59.                 fcirc px(j), py(j), pR
  60.                 snd 120 + py(j) / ymax * 5000, px(j) / xmax * 55
  61.                 EXIT FOR
  62.             END IF
  63.         NEXT
  64.         FOR j = i + 1 TO n
  65.             IF j <> i AND c(j) <> 1 THEN
  66.                 IF SQR((x(i) - x(j)) ^ 2 + (y(i) - y(j)) ^ 2) < rd(i) + rd(j) THEN
  67.                     a(i) = _ATAN2(y(i) - y(j), x(i) - x(j))
  68.                     a(j) = _ATAN2(y(j) - y(i), x(j) - x(i))
  69.                     c(i) = 1: c(j) = 1
  70.                     EXIT FOR
  71.                 END IF
  72.             END IF
  73.         NEXT
  74.  
  75.         'update balls
  76.         dx = COS(a(i)) * speed
  77.         dy = SIN(a(i)) * speed + gravity
  78.         a(i) = _ATAN2(dy, dx)
  79.         x(i) = x(i) + COS(a(i)) * speed
  80.         y(i) = y(i) + SIN(a(i)) * speed
  81.  
  82.         IF x(i) < rd(i) OR x(i) > xmax + rd(i) OR y(i) > ymax + rd(i) THEN
  83.             x(i) = rand(xmax / 2 - 10, xmax / 2 + 10)
  84.             y(i) = rand(-250, -bR)
  85.             a(i) = _PI(.5) + _PI(1 / 90) * rdir
  86.         END IF
  87.         IF a(i) > _PI(2) THEN a(i) = a(i) - _PI(2)
  88.         IF a(i) < 0 THEN a(i) = a(i) + _PI(2)
  89.  
  90.         FOR r = rd(i) TO 1 STEP -1
  91.             COLOR _RGB(255 - rr(i) - 150 * r / rd(i), 255 - gg(i) - 150 * r / rd(i), 255 - bb(i) - 150 * r / rd(i))
  92.             fcirc x(i), y(i), r
  93.         NEXT
  94.         c(i) = 0
  95.     NEXT
  96.     _DISPLAY
  97.     _LIMIT 20
  98. FUNCTION rand (lo, hi)
  99.     rand = (RND * (hi - lo + 1)) \ 1 + lo
  100. FUNCTION rdir ()
  101.     IF RND < .5 THEN rdir = -1 ELSE rdir = 1
  102. 'Steve McNeil's  copied from his forum   note: Radius is too common a name
  103. SUB fcirc (CX AS LONG, CY AS LONG, R AS LONG)
  104.     DIM subRadius AS LONG, RadiusError AS LONG
  105.     DIM X AS LONG, Y AS LONG
  106.  
  107.     subRadius = ABS(R)
  108.     RadiusError = -subRadius
  109.     X = subRadius
  110.     Y = 0
  111.  
  112.     IF subRadius = 0 THEN PSET (CX, CY): EXIT SUB
  113.  
  114.     ' Draw the middle span here so we don't draw it twice in the main loop,
  115.     ' which would be a problem with blending turned on.
  116.     LINE (CX - X, CY)-(CX + X, CY), , BF
  117.  
  118.     WHILE X > Y
  119.         RadiusError = RadiusError + Y * 2 + 1
  120.         IF RadiusError >= 0 THEN
  121.             IF X <> Y + 1 THEN
  122.                 LINE (CX - Y, CY - X)-(CX + Y, CY - X), , BF
  123.                 LINE (CX - Y, CY + X)-(CX + Y, CY + X), , BF
  124.             END IF
  125.             X = X - 1
  126.             RadiusError = RadiusError - X * 2
  127.         END IF
  128.         Y = Y + 1
  129.         LINE (CX - X, CY - Y)-(CX + X, CY - Y), , BF
  130.         LINE (CX - X, CY + Y)-(CX + X, CY + Y), , BF
  131.     WEND
  132. SUB snd (frq, dur)
  133.     SOUND frq / 2.2, dur * .01
  134.  

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Bonkers Symphony No. 37
« Reply #1 on: September 30, 2018, 06:20:20 pm »
I haven't seen or heard the likes of this behavior since my Atari caught a virus. Bad cartridge from the Russian underground.
You're not done when it works, you're done when it's right.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Bonkers Symphony No. 37
« Reply #2 on: September 30, 2018, 08:52:44 pm »
No Atari's were harmed in the making of this code.

The Russians are underground now?