Author Topic: Let's PLAY(0) Wheel of Fortune...  (Read 2946 times)

0 Members and 1 Guest are viewing this topic.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Let's PLAY(0) Wheel of Fortune...
« on: October 21, 2021, 10:24:13 pm »

Code: QB64: [Select]
  1. DIM SHARED overlay
  2.  
  3. Screen0 = _NEWIMAGE(80, 25, 0)
  4. SCREEN Screen0
  5.  
  6. COLOR 8, 0
  7. FOR i = 1 TO 25
  8.     LOCATE i, 1: PRINT STRING$(80, 176);
  9.  
  10. font = _LOADFONT("lucon.ttf", 60, "monospace")
  11. IF font <= 0 THEN font = 16
  12.  
  13. _DEST overlay
  14. _FONT font
  15. COLOR _RGB(255, 102, 0), 0
  16.  
  17. b = 73
  18.  
  19. FOR i = 0 TO 7
  20.     IF i <> 4 THEN LINE (25 + i * b + 18, 55)-(76 + i * b + 18, 125 - 10), _RGB(255, 255, 255), B , 255
  21.  
  22. FOR i = 1 TO 5
  23.     LINE (25 + i * b + 54, 175)-(76 + i * b + 54, 245 - 10), _RGB(255, 255, 255), B , 255
  24.  
  25. Overlay_Hardware = _COPYIMAGE(overlay, 33)
  26. _PUTIMAGE (0, 0), Overlay_Hardware
  27.  
  28.  
  29. FOR i = 1 TO 8
  30.     READ z$, q, w
  31.     t$(i) = z$: q(i) = q: w(i) = w
  32.  
  33. FOR i = 1 TO 8
  34.     FOR j = 1 TO 8
  35.         IF i <> j THEN
  36.             IF q(i) < q(j) THEN SWAP t$(i), t$(j): SWAP q(i), q(j): SWAP w(i), w(j)
  37.         END IF
  38.     NEXT
  39.  
  40. FOR h = 1 TO 8
  41.     IF w(h) < 10 THEN
  42.         t$ = t$(h)
  43.         x = 2.5 + (w(h) - 1) * 2: y = 2
  44.         PSL y, x, t$
  45.     ELSE
  46.         t$ = t$(h)
  47.         x = 3.5 + (w(h) - 9) * 2: y = 4
  48.         PSL y, x, t$
  49.     END IF
  50.     IF h <> 2 THEN _DELAY 3
  51.  
  52. y = 20: x = 23
  53. COLOR _RGB(255, 255, 255)
  54. t$ = "I'd like to solve the puzzle, please!"
  55. PSL y, x, t$
  56.  
  57.  
  58.  
  59. _DEST overlay
  60.  
  61. COLOR _RGB(255, 102, 0), 0
  62.  
  63. x = 0: y = 0: t$ = ""
  64. font = _LOADFONT("lucon.ttf", 60, "monospace")
  65. IF font <= 0 THEN font = 16
  66. _FONT font
  67.  
  68. a$ = CHR$(76) + CHR$(101) + CHR$(116) + "'" + CHR$(115) + CHR$(32) + CHR$(71) + CHR$(111) + CHR$(32) + CHR$(66) + CHR$(114) + CHR$(97) + CHR$(110) + CHR$(100) + CHR$(111) + CHR$(110) + "!"
  69. m$ = "MBn29L3n24L3n33L3n29L4"
  70.  
  71.     IF seed% = 0 THEN PLAY m$
  72.     y = 150: x = 8 + x + LEN(t$) * 36
  73.     t$ = MID$(a$ + " ", seed%, INSTR(seed%, a$ + " ", " ") - seed% + 1)
  74.     _PRINTSTRING (x, y), RTRIM$(t$)
  75.     Overlay_Hardware = _COPYIMAGE(overlay, 33)
  76.     _PUTIMAGE (0, 0), Overlay_Hardware
  77.     _DISPLAY
  78.     IF seed% < LEN(a$) THEN
  79.         seed% = INSTR(seed%, a$ + " ", " ") + 1
  80.         _DELAY .66
  81.     ELSE
  82.         _DELAY .66: CLS: _DISPLAY: seed% = 0: x = 0: _DELAY 1.33
  83.     END IF
  84. _FREEIMAGE overlay
  85.  
  86. _DELAY .66
  87.  
  88.  
  89. DATA C,8,3
  90. DATA K,4,4
  91. DATA B,7,10
  92. DATA J,5,6
  93. DATA F,1,1
  94. DATA E,2,8
  95. DATA N,6,14
  96. DATA E,3,13
  97.  
  98. SUB PSL (y, x, t$)
  99.     _PRINTSTRING ((x - 1) * _FONTWIDTH, (y - 1) * _FONTHEIGHT), t$
  100.     overlay_hardware = _COPYIMAGE(overlay, 33)
  101.     _PUTIMAGE (0, 0), overlay_hardware
  102.     _DISPLAY

Well, on a serious "note," It's a shame QB64 was not able to get the PLAY(0) function implemented. PLAY(0) was a QB / QuickBASIC function that tracked the number notes (up to 36) in the buffer if the MB handle was used to tell PLAY to play the notes in the background. You could use it to figure out where you were in a music loop, or when the last note ended. Very useful.

So my question is probably to @SpriggsySpriggs

Is there a Windows API method to track the sound buffer, or at least to tell us when sound playing sound / music in the background has completed? 

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

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Let's PLAY(0) Wheel of Fortune...
« Reply #1 on: October 22, 2021, 11:08:08 am »
Ah, it's a version incompatibility issue. It runs correctly in 2.0, but in 1.3, it misplaces and overlaps the letters, as you described. Apparently _FONTWIDTH and _FONTHEIGHT are not processed the same in the older versions.

Try this, if you'd like to see the real puzzle...

Change this one line in the PSL() sub...

_PRINTSTRING ((x - 1) * _FONTWIDTH, (y - 1) * _FONTHEIGHT), t$

to...

_PRINTSTRING ((x - 1) * 36, (y - 1) * 60), t$

That should do it.

BTW: What's the version of QB64 you are currently running? $COLOR:32 is another one that won't run in 1.3, but I believe does in 1.4.

Pete

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