Author Topic: One Key Creep Out for Halloween  (Read 3659 times)

0 Members and 1 Guest are viewing this topic.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
One Key Creep Out for Halloween
« on: October 25, 2021, 11:20:29 pm »
One Key Creep Out for Halloween - takes a little practice. With the paddle moving a Spacebar press stops paddle another press, reverses direction and moves again, another press stops, another reverses direction and moves again.

Hint: overshoot paddle target a bit if off you will start going in correct direction with next spacebar press.

Code: QB64: [Select]
  1. _Title "One Key Creep Out for Halloween" 'B+  from Creep Out started 2021-08-18  Breakout with Spiders
  2. ' 2021-08-20A more sounds for breaking bricks font to replace text sub
  3. ' 2021-10-25 fix up Menu now that I know more about Fonts, one key = Spacebar
  4. ' Spacebar toggles menu choices and moving\stopping the paddle.
  5.  
  6. ' =============================  Paddle Play with Spacebar Only! =================================
  7.  
  8. ' Paddle on each Spacebar press: Moves Stops Reverses Stops Reverses Stops Reverses Stops...
  9.  
  10. ' Hint: over shoot paddle placement so if too much you will start right up again going back!
  11.  
  12. ' ================================================================================================
  13.  
  14.  
  15. Const xmax = 700 '<==== drawing area width
  16. Const ymax = 560 '<==== drawing area height
  17.  
  18. 'colors used
  19. Const red = &HFFEE0033
  20. Const orange = &HFFFF8400
  21. Const green = &HFF008000
  22. Const yellow = &HFFFFFF00
  23. Const silver = &HFFD0C6C6
  24. Const white = &HFFFFFFFF
  25. Const black = &HFF000000
  26.  
  27. ' wall is 50 pixels X 14 columns wide = 700 make screen width
  28. ' wall is 20 pixels X 8  rows = 160 = 1/3 screen height = 480 + 20  paddle height
  29. ' under paddle track score and lifes on one line padded by blank lines 540 = 27
  30. ' so total height 480 to paddle 500 + 60 for 3 lines = 560 (text height 20)
  31.  
  32. Const br = 10 ' ball radius
  33. Const bkw = 50 ' brick width
  34. Const bkh = 20 ' brick height
  35.  
  36. Const nSpinners = 112
  37. Const air_resistance = .1
  38.  
  39. Type Object
  40.     x As Single
  41.     y As Single
  42.     dx As Single
  43.     dy As Single
  44.     sz As Single
  45.     c As _Unsigned Long
  46.     dead As Long
  47.  
  48. Dim Shared As Integer nS, pOFF, dMode
  49. Dim Shared dots(2000) As Object
  50.  
  51. ' Sound sources mainly Sound Bible picks from both johnno56 and myself here: https://soundbible.com
  52. ' from Cobalt's advanced version of my eRATication, rar here: https://www.qb64.org/forum/index.php?topic=370.msg2677#msg2677
  53. ' from Filleppes Cloned Shades here: https://www.qb64.org/forum/index.php?topic=1262.msg104706#msg104706
  54.  
  55. Dim Shared As Long mush, alive, laser, whistle, crunch, pop, uh, gong
  56. mush = _SndOpen("mush.wav") ' brick 0 breaking        johnno soundbible
  57. alive = _SndOpen("life.wav") ' brick 1 breaking       Colbalt eRATication
  58. laser = _SndOpen("laser.wav") ' brick 2 breaking      mark soundbible
  59. whistle = _SndOpen("whistle.ogg") ' brick 3 fellippe  Clone-Shades master
  60. crunch = _SndOpen("crunch.wav") ' ball over spider    johnno  soundbible
  61. pop = _SndOpen("pop.wav") ' bouce off wall or paddle  mark soundbible
  62. uh = _SndOpen("playerdie.mp3") ' paddle miss          Colbalt eRATication
  63. gong = _SndOpen("gong.wav") ' complete a screen       mark soundbible
  64. 'Print mush, alive, laser, whistle 'ok
  65. 'Print crunch, pop, uh, gong 'ok
  66. 'End
  67.  
  68. Screen _NewImage(xmax, ymax, 32)
  69.  
  70. '_FullScreen
  71. ' OR   >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> You can choose Full Screen or Centered on screen 700 x 560
  72. _Delay .25
  73.  
  74. Color white, black
  75. f& = _LoadFont("spiders.ttf", 64) ' License included in zip package
  76.  
  77. Dim Shared bx, by, dx, dy, px, py, pw, plf, prt, pf, score, life, hits, obk, rbk, speedups
  78. bx = 0 ' ball x position
  79. by = 0 ' ball y position
  80. dx = 0 ' ball horizontal change
  81. dy = 0 ' ball vertical change
  82.  
  83. restart:
  84. px = 350 ' paddle x, y
  85. py = 450 ' fix paddle sticking at 480
  86. pw = 70 ' paddle width,  100 wide to start half that at certain point
  87. plf = 0 ' paddle left side
  88. prt = 0 ' paddle right side
  89. pf = 1 ' paddle fraction that gets changed according menu choice easy .75, hard .5
  90. nS = 0 ' number of spinners
  91. score = 0
  92. life = 5 '  (or balls left) only 3 allowed according to wiki
  93. hits = 0 ' bricks busted
  94. obk = 0 ' first orange brick hits bool
  95. rbk = 0 ' first red brick hit bool, when this happens paddle width is cut in half!
  96. speedups = 0 ' count, bump up dy when hits = 4 and 8, then with first orange, then with first red
  97. scrn = 0
  98.  
  99. Dim Shared wc(13, 7), wp(13, 7) 'brick wall colors, brick wall points according to color
  100. ' get 448 points clear 1 screen/wall, perfect game is clearing 2 screens/walls
  101. ReDim Shared s(1 To nSpinners) As Object
  102.  
  103. 'Menu
  104. initwall
  105. life = 0
  106. my = 0: t = Timer
  107. While life = 0
  108.     drawtable
  109.     Line (.23 * xmax, .14 * ymax)-(.77 * xmax, .81 * ymax), &HFF0000FF, BF
  110.     Line (.24 * xmax, .15 * ymax)-(.76 * xmax, .8 * ymax), &HFF880000, BF
  111.     Line (.245 * xmax, .16 * ymax)-(.755 * xmax, .79 * ymax), &HFFFFFFFF, B
  112.     Color , &HFF880000
  113.     _PrintString (.257 * xmax, .2 * ymax), "Creep Out Menu"
  114.     _PrintString (.44 * xmax, .2 * ymax + 110), "Easy"
  115.     _PrintString (.44 * xmax, .2 * ymax + 180), "Hard"
  116.     _PrintString (.44 * xmax, .2 * ymax + 250), "Quit"
  117.     Color , &HFF000000
  118.     'While _MouseInput: Wend
  119.     'mx = _MouseX: my = _MouseY: mb = _MouseButton(1)
  120.     drawSpinner xmax * .35, .2 * ymax + 75 + my * 70, .5, 0, &HFF006600
  121.     If InKey$ = " " Then
  122.         t = Timer
  123.         my = my + 1
  124.         If my > 3 Then my = 0
  125.     End If
  126.     If Timer - t > 2 And my > 0 Then
  127.         If my = 1 Then
  128.             life = 5: pf = .75
  129.         ElseIf my = 2 Then 'hard
  130.             life = 3: pf = .5
  131.         ElseIf my = 3 Then
  132.             System 'quit
  133.         End If
  134.     End If
  135.     _Limit 40
  136.     _Display
  137. Color , black
  138. drawtable
  139. initball 'set dx, dy, bx, by ball position and change
  140. updatescore
  141. dMode = 1
  142. While life And _KeyDown(27) = 0
  143.     drawtable
  144.     drawpaddle
  145.     drawball
  146.     handleSpinners
  147.     updatescore
  148.     If hits = 112 And scrn = 0 Then 'setup new
  149.         _SndPlay gong
  150.         _Delay 1
  151.         scrn = 1
  152.         speedups = 0: obk = 0: rbk = 0: pw = 50
  153.         nS = 0
  154.         ReDim s(1 To nSpinners) As Object
  155.         initwall
  156.         drawtable
  157.         initball
  158.     Else
  159.         If hits = 224 Then
  160.             _SndPlay gong
  161.             Color white
  162.             'Text 65, 170, 32, white, "Congratulations on a perfect score!!!"
  163.             _PrintString (35, 175), "Perfect Score!"
  164.             _Delay 3
  165.             Exit While
  166.         End If
  167.     End If
  168.     _Display
  169.     _Limit 20 '< adjust as needed for speed of your system
  170. Color white
  171. 'Text 260, 290, 48, white, "Game Over"
  172. centerText 0, xmax, ymax / 2, "Game Over"
  173. GoTo restart
  174.  
  175. Sub initwall
  176.     Dim cr As _Unsigned Long
  177.     For r = 0 To 7
  178.         Select Case r
  179.             Case 0, 1: cr = red: p = 7
  180.             Case 2, 3: cr = orange: p = 5
  181.             Case 4, 5: cr = green: p = 3
  182.             Case 6, 7: cr = yellow: p = 1
  183.         End Select
  184.         For c = 0 To 13
  185.             wc(c, r) = cr: wp(c, r) = p
  186.         Next
  187.     Next
  188.  
  189. Sub initball 'set ball in play with location and dx, dy
  190.     bx = 350
  191.     by = 280
  192.     dx = rand(1, 4)
  193.     If rand(0, 1) Then dx = -1 * dx
  194.     dy = (3 + speedups) * -1
  195.     px = bx
  196.  
  197. Sub drawtable ' in JB don't want to redraw this every loop
  198.     Cls
  199.     For r = 0 To 7
  200.         For c = 0 To 13
  201.             If wp(c, r) Then
  202.                 For i = 1 To 10
  203.                     'underneath
  204.                     Color _RGB32(120, 60, 60)
  205.                     Line (c * bkw + i, r * bkh + bkh + i)-(c * bkw + bkw + i, r * bkh + bkh + i)
  206.                     Color silver
  207.                     PSet (c * bkw + i, r * bkh + bkh + i)
  208.                     'ink(white)
  209.                     'sidewall
  210.                     Line (c * bkw + bkw + i, r * bkh + i)-(c * bkw + bkw + i, r * bkh + bkh + i)
  211.                 Next
  212.                 Color wc(c, r)
  213.                 Line (c * bkw, r * bkh)-(c * bkw + bkw, r * bkh + bkh), , BF
  214.                 Color white
  215.                 Line (c * bkw, r * bkh)-(c * bkw + bkw, r * bkh + bkh), , B
  216.             End If
  217.         Next
  218.     Next
  219.     'Line (0, 300)-(xmax, 490), &HFF000019, BF ' mouse paddle limit
  220.  
  221. Sub drawpaddle ' update paddle to mouseY, paddle top and bottom are global
  222.  
  223.     'While _MouseInput: Wend
  224.     'px = _MouseX 'update paddle location
  225.     'If _MouseY >= 300 And _MouseY < 480 Then py = _MouseY
  226.     py = 440
  227.     'If InKey$ = " " Then   ' reverse every time you hit spacebar
  228.     '    dMode = 1 - dMode
  229.     '    _KeyClear
  230.     'End If
  231.     'If dMode Then px = px + 10 Else px = px - 10
  232.     'If px < -pw Then px = -pw
  233.     'If px > xmax + pw Then px = xmax + pw
  234.  
  235.     ' stop reverse stop reverse stop reverse
  236.     If InKey$ = " " Then ' reverse every time you hit spacebar  1 0 -1 0 1 0 -1...
  237.         dMode = dMode + 1
  238.         If dMode = 4 Then dMode = 0
  239.         _KeyClear
  240.     End If
  241.     If dMode = 1 Then px = px - 10
  242.     If dMode = 3 Then px = px + 10
  243.     If px < -pw Then px = -pw + 1
  244.     If px > xmax + pw Then px = xmax + pw - 1
  245.  
  246.     plf = px - pw
  247.     prt = px + pw
  248.     For i = 1 To 10
  249.         Color _RGB32(120, 60, 60)
  250.         Line (px - pw + i, py + 10 + i)-(px + pw + i, py + 10 + i), _RGB32(120, 60, 60)
  251.         Color silver
  252.         'PSet (c * bkw + i, r * bkh + bkh + i)
  253.         'ink(white)
  254.         Line (px + pw + i, py + i)-(px + pw + i, py + 10 + i), silver
  255.     Next
  256.     Line (px - pw, py)-(px + pw, py + 10), &HFFAA5533, BF
  257.  
  258. Sub drawball
  259.     'update
  260.     bx = bx + dx
  261.     If bx < br Then dx = dx * -1: bx = br + 1: _SndPlay pop
  262.     If bx > xmax - br Then dx = dx * -1: bx = xmax - br - 1: _SndPlay pop
  263.  
  264.     by = by + dy
  265.     If by + br > py Then 'ball past paddle line
  266.         by = py - br 'don't let ball go into paddle or goal
  267.         If bx + br < plf Or bx - br > prt Then 'paddle miss
  268.             life = life - 1
  269.             _SndPlay uh
  270.             ' if life = 0 then end game
  271.             updatescore
  272.             silverball bx, by
  273.             _Delay 2.5 'reflect on position of ball and loss of life
  274.             CircleFill bx, by, br, black
  275.             initball 'get ball rolling again
  276.         Else 'paddle hit  ' redo according to distance from paddle center
  277.             _SndPlay pop
  278.             dy = dy * -1
  279.             If bx < px Then
  280.                 per = .5 * (px - bx) / pw
  281.                 dx = dx - 6 * per
  282.             ElseIf bx > px Then
  283.                 per = .5 * (bx - px) / pw
  284.                 dx = dx + 6 * per
  285.                 'Else  dx remains same
  286.             End If
  287.             'dx = dx + rand(-2, 2)
  288.             If dx > 7 Then: dx = 7:
  289.             If dx < -7 Then dx = -7
  290.         End If
  291.     Else
  292.         If by - br < 0 Then 'ball hits back border, reverse direction
  293.             _SndPlay pop
  294.             by = br: dy = dy * -1
  295.         Else
  296.             If by - br < 160 Then 'in wall area, what row and column?
  297.                 starthits = hits
  298.                 'maybe should check all 4 corners or smaller ball
  299.                 row = Int((by - br) / bkh): col = Int((bx - br) / bkw)
  300.                 handleBall row, col
  301.                 row = Int((by - br) / bkh): col = Int((bx + br) / bkw)
  302.                 handleBall row, col
  303.                 row = Int((by + br) / bkh): col = Int((bx - br) / bkw)
  304.                 handleBall row, col
  305.                 row = Int((by + br) / bkh): col = Int((bx + br) / bkw)
  306.                 handleBall row, col
  307.                 If hits <> starthits Then: dy = dy * -1: 'reverse ball direction
  308.             End If
  309.         End If
  310.     End If
  311.     silverball bx, by
  312.  
  313. Sub handleBall (row, col)
  314.     If 0 <= row And row <= 7 And 0 <= col And col <= 13 Then
  315.         If wp(col, row) Then 'brick just hit, lot's to do before update ball
  316.             hits = hits + 1
  317.             sp = rand(0, 3)
  318.             Select Case sp
  319.                 Case 0: _SndPlay mush
  320.                 Case 1: _SndPlay alive
  321.                 Case 2: _SndPlay laser
  322.                 Case 3: _SndPlay whistle
  323.             End Select
  324.             nS = nS + 1
  325.             newSpinner nS, col, row
  326.             If hits = 4 Or hits = 8 Or hits = 116 Or hits = 120 Then
  327.                 speedups = speedups + 1
  328.                 If dy < 0 Then dy = dy - .25 Else dy = dy + .25
  329.             End If
  330.             value = wp(col, row)
  331.             If value = 5 Then 'first orange brick
  332.                 If obk = 0 Then 'flag first orange speed increase
  333.                     obk = 1
  334.                     speedups = speedups + 1
  335.                     If dy < 0 Then: dy = dy - .25 Else dy = dy + .25
  336.                 End If
  337.             End If
  338.             If value = 7 Then 'flag first red, speed increase paddle decrease! ! ! !
  339.                 If rbk = 0 Then
  340.                     rbk = 1
  341.                     speedups = speedups + 1
  342.                     If dy < 0 Then dy = dy - .25 Else: dy = dy + .25
  343.                     pw = pf * pw
  344.                 End If
  345.             End If
  346.             score = score + wp(col, row) 'update score with point value
  347.             wp(col, row) = 0 'no points here now
  348.  
  349.  
  350.             'black out box  need this?
  351.             'Line (col * bkw, row * bkh)-(col * bkw + bkw, row * bkh + bkh), black, BF
  352.         End If
  353.     End If
  354.  
  355. Sub updatescore
  356.     centerText 0, xmax / 2, 532, "Lives" + Str$(life)
  357.     centerText xmax / 2, xmax, 532, "Score" + Str$(score)
  358.  
  359. Sub silverball (x, y)
  360.     For i = 10 To 1 Step -1
  361.         cc = 255 - i * 20
  362.         CircleFill x, y, i, _RGB32(cc, cc, cc)
  363.     Next
  364.  
  365. Function rand% (lo%, hi%)
  366.     rand% = Int(Rnd * (hi% - lo% + 1)) + lo%
  367.  
  368. Sub CircleFill (CX As Integer, CY As Integer, R As Integer, C As _Unsigned Long)
  369.     ' CX = center x coordinate
  370.     ' CY = center y coordinate
  371.     '  R = radius
  372.     '  C = fill color
  373.     Dim Radius As Integer, RadiusError As Integer
  374.     Dim X As Integer, Y As Integer
  375.     Radius = Abs(R)
  376.     RadiusError = -Radius
  377.     X = Radius
  378.     Y = 0
  379.     If Radius = 0 Then PSet (CX, CY), C: Exit Sub
  380.     Line (CX - X, CY)-(CX + X, CY), C, BF
  381.     While X > Y
  382.         RadiusError = RadiusError + Y * 2 + 1
  383.         If RadiusError >= 0 Then
  384.             If X <> Y + 1 Then
  385.                 Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  386.                 Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  387.             End If
  388.             X = X - 1
  389.             RadiusError = RadiusError - X * 2
  390.         End If
  391.         Y = Y + 1
  392.         Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  393.         Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  394.     Wend
  395.  
  396. Sub newSpinner (i As Integer, col, row) 'set Spinners dimensions start angles, color?
  397.     Dim r
  398.     s(i).x = col * bkw + .5 * bkw
  399.     s(i).y = row * bkh + .5 * bkh
  400.     s(i).sz = Rnd * .65 + .1
  401.     If Rnd < .5 Then r = -1 Else r = 1
  402.     s(i).dx = (s(i).sz * Rnd * 6) * r * 2
  403.     s(i).dy = (s(i).sz * Rnd * 6) * r * 2
  404.     r = Rnd * 255
  405.     s(i).c = _RGB32(r, Rnd * .5 * r, Rnd * .25 * r)
  406.  
  407. Sub drawSpinner (x As Integer, y As Integer, scale As Single, heading As Single, c As _Unsigned Long)
  408.     Dim x1, x2, x3, x4, y1, y2, y3, y4, r, a, a1, a2, lg, d, rd
  409.     Dim cRed, Blue, cGreen
  410.     Static switch As Integer
  411.     switch = switch + 2
  412.     switch = switch Mod 16 + 1
  413.     cRed = _Red32(c): cGreen = _Green32(c): Blue = _Blue32(c)
  414.     r = 10 * scale
  415.     x1 = x + r * Cos(heading): y1 = y + r * Sin(heading)
  416.     r = 2 * r 'lg lengths
  417.     For lg = 1 To 8
  418.         If lg < 5 Then
  419.             a = heading + .9 * lg * _Pi(1 / 5) + (lg = switch) * _Pi(1 / 10)
  420.         Else
  421.             a = heading - .9 * (lg - 4) * _Pi(1 / 5) - (lg = switch) * _Pi(1 / 10)
  422.         End If
  423.         x2 = x1 + r * Cos(a): y2 = y1 + r * Sin(a)
  424.         drawLink x1, y1, 3 * scale, x2, y2, 2 * scale, _RGB32(cRed + 20, cGreen + 10, Blue + 5)
  425.         If lg = 1 Or lg = 2 Or lg = 7 Or lg = 8 Then d = -1 Else d = 1
  426.         a1 = a + d * _Pi(1 / 12)
  427.         x3 = x2 + r * 1.5 * Cos(a1): y3 = y2 + r * 1.5 * Sin(a1)
  428.         drawLink x2, y2, 2 * scale, x3, y3, scale, _RGB32(cRed + 35, cGreen + 17, Blue + 8)
  429.         rd = Int(Rnd * 8) + 1
  430.         a2 = a1 + d * _Pi(1 / 8) * rd / 8
  431.         x4 = x3 + r * 1.5 * Cos(a2): y4 = y3 + r * 1.5 * Sin(a2)
  432.         drawLink x3, y3, scale, x4, y4, scale, _RGB32(cRed + 50, cGreen + 25, Blue + 12)
  433.     Next
  434.     r = r * .5
  435.     fcirc x1, y1, r, _RGB32(cRed - 20, cGreen - 10, Blue - 5)
  436.     x2 = x1 + (r + 1) * Cos(heading - _Pi(1 / 12)): y2 = y1 + (r + 1) * Sin(heading - _Pi(1 / 12))
  437.     fcirc x2, y2, r * .2, &HFFFFAA00
  438.     x2 = x1 + (r + 1) * Cos(heading + _Pi(1 / 12)): y2 = y1 + (r + 1) * Sin(heading + _Pi(1 / 12))
  439.     fcirc x2, y2, r * .2, &HFFFFAA00
  440.     r = r * 2
  441.     x1 = x + r * .9 * Cos(heading + _Pi): y1 = y + r * .9 * Sin(heading + _Pi)
  442.     TiltedEllipseFill 0, x1, y1, r, .7 * r, heading + _Pi, _RGB32(cRed, cGreen, Blue)
  443.  
  444. Sub drawLink (x1, y1, r1, x2, y2, r2, c As _Unsigned Long)
  445.     Dim a, a1, a2, x3, x4, x5, x6, y3, y4, y5, y6
  446.     a = _Atan2(y2 - y1, x2 - x1)
  447.     a1 = a + _Pi(1 / 2)
  448.     a2 = a - _Pi(1 / 2)
  449.     x3 = x1 + r1 * Cos(a1): y3 = y1 + r1 * Sin(a1)
  450.     x4 = x1 + r1 * Cos(a2): y4 = y1 + r1 * Sin(a2)
  451.     x5 = x2 + r2 * Cos(a1): y5 = y2 + r2 * Sin(a1)
  452.     x6 = x2 + r2 * Cos(a2): y6 = y2 + r2 * Sin(a2)
  453.     fquad x3, y3, x4, y4, x5, y5, x6, y6, c
  454.     fcirc x1, y1, r1, c
  455.     fcirc x2, y2, r2, c
  456.  
  457. 'need 4 non linear points (not all on 1 line) list them clockwise so x2, y2 is opposite of x4, y4
  458. Sub fquad (x1 As Integer, y1 As Integer, x2 As Integer, y2 As Integer, x3 As Integer, y3 As Integer, x4 As Integer, y4 As Integer, c As _Unsigned Long)
  459.     ftri x1, y1, x2, y2, x4, y4, c
  460.     ftri x3, y3, x4, y4, x1, y1, c
  461.  
  462. Sub ftri (x1, y1, x2, y2, x3, y3, K As _Unsigned Long)
  463.     Dim a&
  464.     a& = _NewImage(1, 1, 32)
  465.     _Dest a&
  466.     PSet (0, 0), K
  467.     _Dest 0
  468.     _MapTriangle _Seamless(0, 0)-(0, 0)-(0, 0), a& To(x1, y1)-(x2, y2)-(x3, y3)
  469.     _FreeImage a& '<<< this is important!
  470.  
  471. Sub fcirc (CX As Integer, CY As Integer, R As Integer, C As _Unsigned Long)
  472.     Dim Radius As Integer, RadiusError As Integer
  473.     Dim X As Integer, Y As Integer
  474.     Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0
  475.     If Radius = 0 Then PSet (CX, CY), C: Exit Sub
  476.     Line (CX - X, CY)-(CX + X, CY), C, BF
  477.     While X > Y
  478.         RadiusError = RadiusError + Y * 2 + 1
  479.         If RadiusError >= 0 Then
  480.             If X <> Y + 1 Then
  481.                 Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  482.                 Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  483.             End If
  484.             X = X - 1
  485.             RadiusError = RadiusError - X * 2
  486.         End If
  487.         Y = Y + 1
  488.         Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  489.         Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  490.     Wend
  491.  
  492. Sub TiltedEllipseFill (destHandle&, x0, y0, a, b, ang, c As _Unsigned Long)
  493.     Dim max As Integer, mx2 As Integer, i As Integer, j As Integer, k As Single, lasti As Single, lastj As Single
  494.     Dim prc As _Unsigned Long, tef As Long
  495.     prc = _RGB32(255, 255, 255, 255)
  496.     If a > b Then max = a + 1 Else max = b + 1
  497.     mx2 = max + max
  498.     tef = _NewImage(mx2, mx2)
  499.     _Dest tef
  500.     _Source tef 'point wont read without this!
  501.     For k = 0 To 6.2832 + .05 Step .1
  502.         i = max + a * Cos(k) * Cos(ang) + b * Sin(k) * Sin(ang)
  503.         j = max + a * Cos(k) * Sin(ang) - b * Sin(k) * Cos(ang)
  504.         If k <> 0 Then
  505.             Line (lasti, lastj)-(i, j), prc
  506.         Else
  507.             PSet (i, j), prc
  508.         End If
  509.         lasti = i: lastj = j
  510.     Next
  511.     Dim xleft(mx2) As Integer, xright(mx2) As Integer, x As Integer, y As Integer
  512.     For y = 0 To mx2
  513.         x = 0
  514.         While Point(x, y) <> prc And x < mx2
  515.             x = x + 1
  516.         Wend
  517.         xleft(y) = x
  518.         While Point(x, y) = prc And x < mx2
  519.             x = x + 1
  520.         Wend
  521.         While Point(x, y) <> prc And x < mx2
  522.             x = x + 1
  523.         Wend
  524.         If x = mx2 Then xright(y) = xleft(y) Else xright(y) = x
  525.     Next
  526.     _Dest destHandle&
  527.     For y = 0 To mx2
  528.         If xleft(y) <> mx2 Then Line (xleft(y) + x0 - max, y + y0 - max)-(xright(y) + x0 - max, y + y0 - max), c, BF
  529.     Next
  530.     _FreeImage tef
  531.  
  532. Sub handleSpinners
  533.     For i = 1 To nS
  534.         If s(i).dead Then
  535.             If s(i).dead < 10 * s(i).sz Then
  536.                 explode s(i).x, s(i).y, 20 * s(i).sz, s(i).dead
  537.                 s(i).dead = s(i).dead + 1
  538.             End If
  539.         Else
  540.             s(i).x = s(i).x + s(i).dx
  541.             If s(i).x < 0 Or s(i).x > xmax Then s(i).dx = -s(i).dx
  542.             s(i).y = s(i).y + s(i).dy
  543.             If s(i).y < 0 Or s(i).y > xmax Then s(i).dy = -s(i).dy
  544.             If Sqr((bx - s(i).x) ^ 2 + (by - s(i).y) ^ 2) < 1.5 * br Then
  545.                 s(i).dead = 1
  546.                 explode s(i).x, s(i).y, 20 * s(i).sz, s(i).dead
  547.                 _SndPlay crunch
  548.             Else
  549.                 drawSpinner s(i).x, s(i).y, s(i).sz, _Atan2(s(i).dy, s(i).dx), s(i).c
  550.             End If
  551.         End If
  552.     Next
  553.  
  554. Sub explode (x, y, r, frm)
  555.     maxParticles = r * 40
  556.     For i = 1 To r
  557.         NewDot i, x, y, r
  558.     Next
  559.     rounds = r
  560.     For loopCount = 0 To frm
  561.         If _KeyDown(27) Then End
  562.         For i = 1 To rounds
  563.             dots(i).x = dots(i).x + dots(i).dx
  564.             dots(i).y = dots(i).y + dots(i).dy
  565.             dots(i).dx = dots(i).dx * air_resistance
  566.             dots(i).dy = air_resistance * dots(i).dy
  567.             fcirc dots(i).x, dots(i).y, dots(i).sz / 2, dots(i).c
  568.         Next
  569.         If rounds < maxParticles Then
  570.             For i = 1 To r
  571.                 NewDot (rounds + i), x, y, r
  572.             Next
  573.             rounds = rounds + r
  574.         End If
  575.     Next
  576.  
  577. Sub NewDot (i, x, y, r)
  578.     angle = _Pi(2 * Rnd)
  579.     rd = Rnd * 30
  580.     dots(i).x = x + rd * Cos(angle)
  581.     dots(i).y = y + rd * Sin(angle)
  582.     dots(i).sz = Rnd * r * .5
  583.     rd = Rnd 'STxAxTIC recommended for rounder spreads
  584.     dots(i).dx = rd * 7 * (7 - dots(i).sz) * Cos(angle)
  585.     dots(i).dy = rd * 7 * (7 - dots(i).sz) * Sin(angle)
  586.     dots(i).c = _RGB32(140 + rd * 80, 70 + rd * 40, 0)
  587.  
  588. Sub centerText (x1, x2, midy, s$) ' ' if you want to center fit a string between two goal posts x1, and x2
  589.     _PrintString ((x1 + x2) / 2 - _PrintWidth(s$) / 2, midy - _FontHeight(_Font) / 2), s$
  590.  
  591.  


zip contaings great sound effects and Spider font with license.

* One Key Creep Out.zip (Filesize: 1.49 MB, Downloads: 175)

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: One Key Creep Out for Halloween
« Reply #1 on: October 26, 2021, 03:21:44 am »
Ah, the old Breakout game from my Atari days, but in 3-D, nice!

Did you ever hear of Atari Warlords? It was a fun 4-player paddle party game. Here's a vid of me, back in the day, Playing against Clippy on the far left bottom.

Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: One Key Creep Out for Halloween
« Reply #2 on: October 26, 2021, 03:48:31 am »
I remember Warlords.  Trick to the game was holding the button on the scrollwheel.  You could catch the ball, then spin real fast, release the button, and launch a superfast strike.  Just blocking the ball wasn't that useful; but blocking it with momentum changed the ball's speed to match yours. 
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: One Key Creep Out for Halloween
« Reply #3 on: October 26, 2021, 12:10:36 pm »
What's Atari?

Hey pretty good if can catch the ball and then lob it out at a target like Lacrosse.

But can it be done with One Key?

PS I got my Breakout directions or specs from Wiki.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: One Key Creep Out for Halloween
« Reply #4 on: October 26, 2021, 03:11:41 pm »
The ability to catch and move the ball in a different direction made the game more exciting. You could target an opponent, once you learned a bit about the angular directions. I got a kick out of the example I posted, as the demo showed how a player could also screw himself! The piece in the center of each "castle" is the king. Destroying the king is all that is required to eliminate an opponent.

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: One Key Creep Out for Halloween
« Reply #5 on: October 27, 2021, 02:08:21 pm »
This is the story behind the change I did with the spiders. They have been munching on the bugs that have been feeding on the pumpkins growing just outside the nuclear plant in Perry, Ohio.