Author Topic: Crypt-O-Gram Puzzle - Halloween Challenge  (Read 7268 times)

0 Members and 1 Guest are viewing this topic.

This topic contains a post which is marked as Best Answer. Press here if you would like to see it.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Crypt-O-Gram Puzzle - Halloween Challenge
« on: October 04, 2021, 09:18:14 am »
The Cryptogram Puzzle I presented in Discussion Board was really sadistic in the way you had to input letters. I came up with a better algorithm yesterday morning, I call it "Binary Select".

Here is the test code you can play with to get familiar with inputting letters. It's like the computer is playing a little guessing game showing you a group of letters and you press spacebar (or any key in test demo) if your letter is in the group... just wait if it's not your letter in group, repeat... until computer knows your letter. The computer then displays letter on next line and on next line you must confirm YN (another little guessing game pressing spacebar (or any key) on the Y display to confirm, indeed, that is the intended letter or not ie, you did not confirm the Y display.

So here is the main engine for getting user input for the game:
Code: QB64: [Select]
  1. _Title "Binary Select test demo" 'b+ 2021-10-03  Aha!
  2.  
  3.     test$ = bChoice$(10, 5, "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234")
  4.     Cls
  5.     Print "bChoice$ returned > "; test$
  6.     Do
  7.         Print: Print "Do you want to try another?"
  8.         test$ = ""
  9.         test$ = bChoice$(CsrLin, 1, "YNM")
  10.     Loop Until Len(test$)
  11.     Cls
  12. Loop Until test$ <> "Y"
  13.  
  14. Function bChoice$ (row, col, select$) ' this is a wrapper function for confirming the BinarySelect$ choice since so easy to mess up
  15.     'this function needs 3 lines from screen, starting at row parameter.
  16.     'the first line, at row, is dedicated to the BinarySelect$ function
  17.     'the next 2 lines confirm the select
  18.     ' All this makes it possible to continuous poll for a selection, if the user is away from computer for awhile
  19.     ' no problem because he wont be there to confirm the choice and so no progress is made in program using BinarySelect$
  20.  
  21.     'clear 3 dedicated lines
  22.     copySelect$ = select$
  23.     For i = 0 To 2 ' clear lines
  24.         Locate row + i, col: Print Space$(_Width - col + 1);
  25.     Next
  26.     c$ = BinarySelect$(row, col, copySelect$) ' the last choice is like a cancel
  27.     'Locate 20, 10: Print "debug print c$: "; c$;
  28.     Locate row + 1, col: Print "Confirming your choice > " + c$;
  29.     check$ = BinarySelect$(row + 2, col, "YN")
  30.     If check$ = "Y" Then bChoice$ = c$
  31.     Print "bChoice$ = "; c$
  32.  
  33.  
  34. Function BinarySelect$ (row, col, select$) ' this is recursive part of Binary Select Algo
  35.     ls = Len(select$)
  36.     If ls = 0 Then Beep: Exit Function ' no choices
  37.     If ls = 1 Then BinarySelect$ = select$: Exit Function ' only one choice
  38.     hls = Int(ls / 2)
  39.     s1$ = Mid$(select$, 1, hls): s2$ = Mid$(select$, hls + 1)
  40.     Locate row, col: Print Space$(_Width - col + 1);
  41.     Locate row, col: Print "Press key if you see your choice > " + s1$;
  42.     t = Timer(.001)
  43.     _KeyClear
  44.     k$ = InKey$
  45.     While Len(k$) = 0 And Timer(.001) - t < 3 + .25 * Len(s1$)
  46.         k$ = InKey$
  47.         _Limit 60
  48.     Wend
  49.     If Len(k$) Then
  50.         If Len(s1$) = 1 Then BinarySelect$ = s1$ Else BinarySelect$ = BinarySelect$(row, col, s1$)
  51.     Else
  52.         BinarySelect$ = BinarySelect$(row, col, s2$)
  53.     End If
  54.  
  55.  

It's still something that needs a little practice with but it is much easier to use than my first idea.

On the confirmation for trying again, it still catches me by surprise the first Y for confirming to try again.
No worries, if there is no confirmation for any letter, it will cycle around and offer the groups over and over again.

For the Game, I put an Ecs keypress in there to quit game as it was in Full Screen mode with no top right window X to close.



Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #1 on: October 04, 2021, 09:57:17 am »
And here is the first version of the Game that I submit for our Challenge here with Screen 0 and hope to work in graphics for Syntax Competition maybe. Credits for jokes are listed right under Title at beginning. The whole thing is under 300 LOC.
Code: QB64: [Select]
  1. _Title "Halloween Challenge: Crypt-O-Gram Puzzle" ' b+  started One Key Challenge 2021-09-25
  2. ' from One Key Challenge - Cryptogram Puzzle   2021-10-02
  3.  
  4. ' 2021-09-07 Jokes are intended for QB64 home programming entertainment use only.
  5. ' Thank you CountryLiving 1-33
  6. ' https://www.countryliving.com/entertaining/a32963261/halloween-jokes/
  7. ' Thank you GoodHousekeeping 34-72
  8. ' https://www.goodhousekeeping.com/holidays/halloween-ideas/a32998753/halloween-jokes/
  9.  
  10. ' 2021-10-03 install new set of jokes and new Binary Select Input Algorithm
  11. ' Redo Mode system to fix differences of input methods.
  12. ' Recolor green background has me seeing Red!
  13.  
  14. Dim Shared Answer$ '  beginning phrase to be guessed    '   3 stages of the Puzzle
  15. Dim Shared Coded$ '   hidden in code
  16. Dim Shared Working$ ' decoded and solved when working$ becomes = ucase$(answer$)
  17. Dim Shared Letters$(1 To 26) ' for coding and highlited letters
  18. Dim Shared LCodes$(1 To 26) '  for code and decode by number 1 to 26
  19. Dim Shared Guesses$(1 To 26) ' track all the guess to decode
  20. Dim Shared HighLited ' cursor over letters to guess
  21. Dim Shared Mode
  22. _FullScreen 'I guess it does make it easier to tell E from F...
  23. Dim jokes$(1 To 100)
  24. For i = 1 To 100
  25.     Read r$
  26.     If r$ <> "EOD" Then jokes$(i) = r$: jCount = jCount + 1 Else Exit For
  27. restart:
  28. Answer$ = jokes$(Int(Rnd * jCount) + 1)
  29. For i = 1 To 26: Guesses$(i) = "-": Next 'setup the display guesses array
  30. For i = 1 To 26 ' use letters for display of letters to pick second and to create a code
  31.     Letters$(i) = Chr$(i + 64)
  32.     LCodes$(i) = Letters$(i) ' these will convert between each other by index number
  33. For i = 26 To 2 Step -1 ' shuffle the letters in LCode$()
  34.     Swap LCodes$(i), LCodes$(Int(Rnd * i) + 1)
  35. Coded$ = "": Working$ = "" ' reset for next go around
  36. For i = 1 To Len(Answer$) 'third: put the phrase in coded$ and hide it in working$
  37.     a = Asc(UCase$(Answer$), i)
  38.     If a >= 65 And a <= 90 Then
  39.         Coded$ = Coded$ + LCodes$(a - 64)
  40.         Working$ = Working$ + "*"
  41.     Else
  42.         Coded$ = Coded$ + Mid$(Answer$, i, 1)
  43.         Working$ = Working$ + Mid$(Answer$, i, 1)
  44.     End If
  45. HighLited = 1 'setup done start game
  46. Mode = 0
  47.     DisplayScreen
  48.     k$ = bChoice$(23, 33, "1234ABCDEFGHIJKLMNOPQRSTUVWXYZ")
  49.     If k$ <> "" Then
  50.         If Mode = 0 Then ' highlight a letter
  51.             'm replaces arrows and mouse select of highlited 1 to 26 for letters
  52.             test = InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", k$)
  53.             If test > 0 Then
  54.                 HighLited = test
  55.                 Mode = 1
  56.             Else
  57.                 test = InStr("1234", k$)
  58.                 If test > 0 Then
  59.                     Select Case test
  60.                         Case 1: GoSub do1
  61.                         Case 2: GoSub do2
  62.                         Case 3: GoSub do3
  63.                         Case 4: GoSub do4
  64.                     End Select
  65.                 Else
  66.                     Mode = 0
  67.                 End If
  68.             End If
  69.         Else
  70.             Select Case k$
  71.                 Case "1": GoSub do1
  72.                 Case "2": GoSub do2
  73.                 Case "3": GoSub do3
  74.                 Case "4": GoSub do4
  75.                 Case "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
  76.                     Guesses$(HighLited) = k$ ' for screen updates
  77.                     For i = 1 To Len(Working$)
  78.                         If Letters$(HighLited) = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = k$
  79.                     Next
  80.                     Mode = 0
  81.             End Select
  82.         End If
  83.     End If
  84.     _Limit 60
  85. Loop Until Working$ = UCase$(Answer$)
  86. DisplayScreen
  87. Color 9, 8
  88. cp 17, "You got it!    5 secs to next puzzle..."
  89. GoTo restart
  90.  
  91. do1: ' display answer
  92. Working$ = UCase$(Answer$) ' show the answer$ guesses correct moves to next puzzle
  93. DisplayScreen
  94. Mode = 0
  95.  
  96. do2: ' get decode letter for highlighted Letter
  97. For i = 1 To 26
  98.     If LCodes$(i) = Letters$(HighLited) Then c$ = Chr$(i + 64): Exit For
  99. Guesses$(HighLited) = c$ ' for screen updates
  100. For i = 1 To Len(Working$)
  101.     If Letters$(HighLited) = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = c$
  102. Mode = 0
  103.  
  104. do3: ' find a uncoded letter
  105. Color 15, 8: Locate 24, 40: Print "Select Find Letter"
  106. d$ = bChoice$(23, 33, "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
  107. If d$ <> "" Then
  108.     c$ = LCodes$(Asc(d$) - 64)
  109.     Guesses$(Asc(c$) - 64) = d$
  110.     For i = 1 To Len(Working$)
  111.         If c$ = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = d$
  112.     Next
  113.     Mode = 0
  114.  
  115. do4: ' clear guess letter from code letter
  116. Guesses$(HighLited) = "-"
  117. For i = 1 To Len(Working$)
  118.     If Letters$(HighLited) = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = "*" ' clear the letter
  119. Mode = 0
  120.  
  121. 'one liners
  122. Data "Why do ghosts go on diets? So they can keep their ghoulish figures"
  123. Data "Where does a ghost go on vacation? Mali-boo."
  124. Data "Why did the ghost go into the bar? For the Boos."
  125. Data "What is in a ghost's nose? Boo-gers."
  126. Data "Why did the policeman ticket the ghost on Halloween? It didn't have a haunting license."
  127. Data "Why do demons and ghouls hang out together? Because demons are a ghoul's best friend!"
  128. Data "Why did the ghost starch his sheet? He wanted everyone scared stiff."
  129. Data "What does a panda ghost eat? Bam-BOO!"
  130. Data "What's a ghost's favorite dessert? I-Scream!"
  131. Data "Where do ghosts buy their food? At the ghost-ery store!"
  132. Data "How do you know when a ghost is sad? He starts boo hooing."
  133. Data "Why don't mummies take time off? They're afraid to unwind."
  134. Data "Why did the headless horseman go into business? He wanted to get ahead in life."
  135. Data "What kind of music do mummies like listening to on Halloween? Wrap music."
  136. Data "Why don't mummies have friends? Because they're too wrapped up in themselves."
  137. Data "Why did the vampire read the newspaper? He heard it had great circulation."
  138. Data "How do vampires get around on Halloween? On blood vessels."
  139. Data "What's it like to be kissed by a vampire? It's a pain in the neck."
  140. Data "What's it called when a vampire has trouble with his house? A grave problem."
  141. Data "How can you tell when a vampire has been in a bakery? All the jelly has been sucked out of the jelly doughnuts."
  142. Data "What do you get when you cross a vampire and a snowman? Frostbite."
  143. Data "Why do skeletons have low self-esteem? They have no body to love."
  144. Data "Know why skeletons are so calm? Because nothing gets under their skin."
  145. Data "What do you call a cleaning skeleton? The grim sweeper."
  146. Data "What do skeletons order at a restaurant? Spare ribs."
  147. Data "What do you call a witch's garage? A broom closet."
  148. Data "What kind of food would you find on a haunted beach? A sand-witch!"
  149. Data "What was the witch's favorite subject in school? Spelling."
  150. Data "What do you call two witches who live together? Broom-mates!"
  151. Data "What's a witch's favorite makeup? Ma-scare-a."
  152. Data "Who helps the little pumpkins cross the road safely? The crossing gourd."
  153. Data "What treat do eye doctors give out on Halloween? Candy corneas."
  154. Data "What type of plants do well on all Hallow's Eve? Bam-BOO!"
  155. Data "What do birds say on Halloween? Trick or tweet!"
  156. Data "Why don't skeletons ever go trick or treating? Because they have no-body to go with."
  157. Data "Where do ghosts buy their Halloween candy? At the ghost-ery store!"
  158. Data "What do owls say when they go trick or treating? 'Happy Owl-ween!'"
  159. Data "What do ghosts give out to trick or treaters? Booberries!"
  160. Data "Who did Frankenstein go trick or treating with? His ghoul friend."
  161. Data "What Halloween candy is never on time for the party? Choco-LATE!"
  162. Data "What do witches put on to go trick or treating? Mas-scare-a."
  163. Data "What does Bigfoot say when he asks for candy?  'Trick-or-feet!'"
  164. Data "Which type of pants do ghosts wear to trick or treat? Boo jeans."
  165. Data "What makes trick or treating with twin witches so challenging? You never know which witch is which!"
  166. Data "What happens when a vampire goes in the snow? Frost bite!"
  167. Data "What do you call two witches living together? Broommates"
  168. Data "What position does a ghost play in hockey? Ghoulie."
  169. Data "What do mummies listen to on Halloween? Wrap music."
  170. Data "How do you make a skeleton laugh? You tickle his funny bone!"
  171. Data "Which Halloween monster is good at math? Count Dracula!"
  172. Data "Why did the Cyclops give up teaching? He only had one pupil!"
  173. Data "Why didn't the skeleton go to see a scary movie? He didn't have the guts."
  174. Data "What did the boy ghost say to the girl ghost? 'You sure are boo-tiful!'"
  175. Data "Where does Dracula keep his money? In a blood bank."
  176. Data "Why are ghosts terrible liars? You can see right through them!"
  177. Data "Why don't mummies take vacations? They're afraid to unwind."
  178. Data "What is a vampire's favorite holiday, besides Halloween? Fangs-giving!"
  179. Data "Where do fashionable ghosts shop? Bootiques!"
  180. Data "What's a monster's favorite play? Romeo and Ghouliet!"
  181. Data "What room does a ghost not need? A living room."
  182. Data "What monster plays tricks on Halloween? Prank-enstein!"
  183. Data "What's a ghost's favorite dessert? I scream."
  184. Data "What does the skeleton chef say when he serves you a meal? 'Bone Appetit!'"
  185. Data "What is a vampire's favorite fruit? A neck-tarine!"
  186. Data "What do witches put on their bagels? Scream cheese."
  187. Data "What do ghosts eat for dinner? Spook-ghetti!"
  188. Data "What do skeletons order at restaurants? Spare ribs."
  189. Data "What does a panda ghost eat? Bam-BOO!"
  190. Data "What tops off a mummy's ice cream sundae? Whipped scream."
  191. Data "What's a ghost's favorite yogurt flavor? Boo-berry!"
  192. Data "What's a vampire's least favorite meal? A steak!"
  193. Data "Why was the candy corn booed off the stage? All of his jokes were too corny!"
  194. Data "EOD"
  195.  
  196. Sub DisplayScreen
  197.     Color 9, 8: Cls
  198.     cp 2, "*** Halloween Challenge - Cryptogram Puzzle ***"
  199.     Color 6
  200.     cp 4, "Solve puzzle by selecting a Code letter then selecting a Guess letter for it."
  201.     cp 5, "All selections are made by pressing spacebar when you see your letter or digit."
  202.     cp 6, "You will need to verify your selection by pressing spacebar again when see Y for Yes."
  203.     cp 7, "Use the escape key to quit immediately (an X box in top right is not accessible)."
  204.     cp 9, "To get the answer and move onto next puzzle, select 1."
  205.     cp 10, "To decode current highlighted letter, select 2."
  206.     cp 11, "To solve a letter, select 3 and then select letter to find."
  207.     cp 12, "To clear a guess at highlighted Code letter, select 4."
  208.     Color 14
  209.     Locate 15, (120 - Len(Answer$)) / 2: Print Coded$
  210.     Color 15
  211.     Locate 16, (120 - Len(Answer$)) / 2
  212.     For i = 1 To Len(Answer$)
  213.         w$ = Mid$(Working$, i, 1): c$ = Mid$(Coded$, i, 1)
  214.         a$ = Mid$(Answer$, i, 1): h$ = Letters$(HighLited)
  215.         If w$ = "*" Then
  216.             pc$ = "*": If h$ = c$ Then Color 15, 9 Else Color 15, 8
  217.         Else
  218.             Color 15, 8: If w$ = UCase$(a$) Then pc$ = a$ Else pc$ = w$
  219.         End If
  220.         Print pc$;
  221.     Next
  222.     spaces = 9
  223.     For i = 1 To 26 'blue background highlighter
  224.         If i = HighLited Then Color 14, 9 Else Color 14, 8
  225.         Locate 19, spaces: Print Letters$(i)
  226.         If i = HighLited Then Color 14, 9 Else Color 15, 8
  227.         Locate 20, spaces: Print Guesses$(i)
  228.         spaces = spaces + 4
  229.     Next
  230.     If Mode = 1 Then
  231.         Color 15, 8
  232.         cp 22, "Guess Solve Letter or Menu #"
  233.     Else
  234.         Color 14, 8
  235.         cp 22, "Select Code Letter or Menu #"
  236.     End If
  237.  
  238. Sub cp (row, text$) ' center text on text screen
  239.     Locate row, (_Width - Len(text$)) / 2: Print text$
  240.  
  241. Function bChoice$ (row, col, select$) ' this is a wrapper function for confirming the BinarySelect$ choice since so easy to mess up
  242.     ' This will return "" if user never confirms a choice, otherwise some letter in Select$ is returned.
  243.     ' Row and Col setup for Locate that works on any screen not like x, y for _PrintString when want to work in graphics or screen 0
  244.     ' The first line, at row, is dedicated to the BinarySelect$ function
  245.     ' the next 2 lines confirm the select using another YN for Yes No Bianary Select.
  246.     ' All this makes it possible to continuous poll for a selection, if the user is away from computer for awhile
  247.     ' no problem because he wont be there to confirm the choice and so no progress is made in program using BinarySelect$.
  248.  
  249.     'clear 3 dedicated lines for Row, Col to end of line
  250.     copySelect$ = select$
  251.     For i = 0 To 2 ' clear lines
  252.         Locate row + i, col: Print Space$(_Width - col + 1);
  253.     Next
  254.     c$ = BinarySelect$(row, col, copySelect$) ' the last choice is like a cancel
  255.     Locate row + 1, col: Print "Confirming your choice > " + c$;
  256.     check$ = BinarySelect$(row + 2, col, "YN")
  257.     If check$ = "Y" Then bChoice$ = c$
  258.  
  259. Function BinarySelect$ (row, col, select$) ' this is recursive part of Binary Select Algo
  260.     ls = Len(select$)
  261.     If ls = 0 Then Beep: Exit Function ' no choices
  262.     If ls = 1 Then BinarySelect$ = select$: Exit Function ' only one choice
  263.     hls = Int(ls / 2)
  264.     s1$ = Mid$(select$, 1, hls): s2$ = Mid$(select$, hls + 1)
  265.     Locate row, col: Print Space$(_Width - col + 1);
  266.     Locate row, col: Print "Press spacebar if you see your choice > " + s1$;
  267.     t = Timer(.001)
  268.     _KeyClear
  269.     k$ = InKey$
  270.     While k$ <> " " And Timer(.001) - t < 3 + .25 * Len(s1$) 'modified for just spacebar
  271.         If _KeyDown(27) Then System ' quit
  272.         k$ = InKey$
  273.         _Limit 60
  274.     Wend
  275.     If Len(k$) Then
  276.         If Len(s1$) = 1 Then BinarySelect$ = s1$ Else BinarySelect$ = BinarySelect$(row, col, s1$)
  277.     Else
  278.         BinarySelect$ = BinarySelect$(row, col, s2$)
  279.     End If
  280.  

Some hints for playing:
* These are all one liner Halloween jokes, so most start with W for What, When, Where, Why sometimes H for How.

Think of them as walking through a cemetery reading grave stones and learning, "The pun that knocked 'em dead"

* When your decode letter is correct, it will show in lower case in the joke unless starts a sentence or is Proper Name, a bad guess will leave the letter capitalized.

* How many one letter words are there? How many 2?

* Frequent double letters are ee ll in Halloween, oo in Boo.

* Frequent words and subjects of the one liners: ghost, witch, skeleton, mummy, monsters.

* If you want the current coded highlighted letter solved without guessing, select (menu item) 2.

* If you have to have an E, S, T, R...  then select (menu item) 3, you will be prompted for the letter in the guessing game way like all the other letters.

* If you want to just clear the highlighted letter guess that is clearly wrong, select (menu item) 4.

* If you totally give up and want to see the solution, select (menu item) 1.

* Coded Letters and prompts are color coded Yellow. Guess-to-Solve letters and prompts are color coded White.




Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #2 on: October 04, 2021, 05:00:27 pm »
OK here is v2021-10-04 with mod of Steve's user input system plus real orange color:
Code: QB64: [Select]
  1. _Title "Halloween Challenge: Crypt-O-Gram Puzzle" ' b+  started One Key Challenge 2021-09-25
  2. ' from One Key Challenge - Cryptogram Puzzle   2021-10-02
  3.  
  4. ' 2021-09-07 Jokes are intended for QB64 home programming entertainment use only.
  5. ' Thank you CountryLiving 1-33
  6. ' https://www.countryliving.com/entertaining/a32963261/halloween-jokes/
  7. ' Thank you GoodHousekeeping 34-72
  8. ' https://www.goodhousekeeping.com/holidays/halloween-ideas/a32998753/halloween-jokes/
  9.  
  10. ' 2021-10-03 install new set of jokes and new Binary Select Input Algorithm
  11. ' Redo Mode system to fix differences of input methods.
  12. ' Recolor green background has me seeing Red!
  13. ' 2021-10-04 Steve McNeill came up with an easier to understand and use input system.
  14. ' Installing new Function and updating Game. Steve also told me how to change color palette,
  15. ' now we have some real Orange! for #12 meant for high red.
  16.  
  17. _PaletteColor 12, _RGB32(255, 128, 0) ' Orange
  18. Dim Shared Answer$ '  beginning phrase to be guessed    '   3 stages of the Puzzle
  19. Dim Shared Coded$ '   hidden in code
  20. Dim Shared Working$ ' decoded and solved when working$ becomes = ucase$(answer$)
  21. Dim Shared Letters$(1 To 26) ' for coding and highlited letters
  22. Dim Shared LCodes$(1 To 26) '  for code and decode by number 1 to 26
  23. Dim Shared Guesses$(1 To 26) ' track all the guess to decode
  24. Dim Shared HighLited ' cursor over letters to guess
  25. Dim Shared Mode
  26. _FullScreen 'I guess it does make it easier to tell E from F...
  27. Dim jokes$(1 To 100)
  28. For i = 1 To 100
  29.     Read r$
  30.     If r$ <> "EOD" Then jokes$(i) = r$: jCount = jCount + 1 Else Exit For
  31. restart:
  32. Answer$ = jokes$(Int(Rnd * jCount) + 1)
  33. For i = 1 To 26: Guesses$(i) = "-": Next 'setup the display guesses array
  34. For i = 1 To 26 ' use letters for display of letters to pick second and to create a code
  35.     Letters$(i) = Chr$(i + 64)
  36.     LCodes$(i) = Letters$(i) ' these will convert between each other by index number
  37. For i = 26 To 2 Step -1 ' shuffle the letters in LCode$()
  38.     Swap LCodes$(i), LCodes$(Int(Rnd * i) + 1)
  39. Coded$ = "": Working$ = "" ' reset for next go around
  40. For i = 1 To Len(Answer$) 'third: put the phrase in coded$ and hide it in working$
  41.     a = Asc(UCase$(Answer$), i)
  42.     If a >= 65 And a <= 90 Then
  43.         Coded$ = Coded$ + LCodes$(a - 64)
  44.         Working$ = Working$ + "*"
  45.     Else
  46.         Coded$ = Coded$ + Mid$(Answer$, i, 1)
  47.         Working$ = Working$ + Mid$(Answer$, i, 1)
  48.     End If
  49. HighLited = 1 'setup done start game
  50. Mode = 0
  51.     DisplayScreen
  52.     k$ = choice$(25, 44, " 1234ABCDEFGHIJKLMNOPQRSTUVWXYZ")
  53.     If k$ <> " " Then
  54.         If Mode = 0 Then ' highlight a letter
  55.             'm replaces arrows and mouse select of highlited 1 to 26 for letters
  56.             test = InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", k$)
  57.             If test > 0 Then
  58.                 HighLited = test
  59.                 Mode = 1
  60.             Else
  61.                 test = InStr("1234", k$)
  62.                 If test > 0 Then
  63.                     Select Case test
  64.                         Case 1: GoSub do1
  65.                         Case 2: GoSub do2
  66.                         Case 3: GoSub do3
  67.                         Case 4: GoSub do4
  68.                     End Select
  69.                 Else
  70.                     Mode = 0
  71.                 End If
  72.             End If
  73.         Else
  74.             Select Case k$
  75.                 Case "1": GoSub do1
  76.                 Case "2": GoSub do2
  77.                 Case "3": GoSub do3
  78.                 Case "4": GoSub do4
  79.                 Case "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
  80.                     Guesses$(HighLited) = k$ ' for screen updates
  81.                     For i = 1 To Len(Working$)
  82.                         If Letters$(HighLited) = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = k$
  83.                     Next
  84.                     Mode = 0
  85.             End Select
  86.         End If
  87.     End If
  88.     _Limit 60
  89. Loop Until Working$ = UCase$(Answer$)
  90. DisplayScreen
  91. Color 12, 8
  92. cp 19, "You got it!    5 secs to next puzzle..."
  93. GoTo restart
  94.  
  95. do1: ' display answer
  96. Working$ = UCase$(Answer$) ' show the answer$ guesses correct moves to next puzzle
  97. DisplayScreen
  98. Mode = 0
  99.  
  100. do2: ' get decode letter for highlighted Letter
  101. For i = 1 To 26
  102.     If LCodes$(i) = Letters$(HighLited) Then c$ = Chr$(i + 64): Exit For
  103. Guesses$(HighLited) = c$ ' for screen updates
  104. For i = 1 To Len(Working$)
  105.     If Letters$(HighLited) = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = c$
  106. Mode = 0
  107.  
  108. do3: ' find a uncoded letter
  109. Color 15, 8: cp 24, "Select Letter to Find"
  110. Locate 25, 1: Print Space$(_Width) ' clear out old line
  111. d$ = choice$(25, 46, " ABCDEFGHIJKLMNOPQRSTUVWXYZ")
  112. If d$ <> " " Then
  113.     c$ = LCodes$(Asc(d$) - 64)
  114.     Guesses$(Asc(c$) - 64) = d$
  115.     For i = 1 To Len(Working$)
  116.         If c$ = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = d$
  117.     Next
  118.     Mode = 0
  119.  
  120. do4: ' clear guess letter from code letter
  121. Guesses$(HighLited) = "-"
  122. For i = 1 To Len(Working$)
  123.     If Letters$(HighLited) = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = "*" ' clear the letter
  124. Mode = 0
  125.  
  126. 'one liners
  127. Data "Why do ghosts go on diets? So they can keep their ghoulish figures"
  128. Data "Where does a ghost go on vacation? Mali-boo."
  129. Data "Why did the ghost go into the bar? For the Boos."
  130. Data "What is in a ghost's nose? Boo-gers."
  131. Data "Why did the policeman ticket the ghost on Halloween? It didn't have a haunting license."
  132. Data "Why do demons and ghouls hang out together? Because demons are a ghoul's best friend!"
  133. Data "Why did the ghost starch his sheet? He wanted everyone scared stiff."
  134. Data "What does a panda ghost eat? Bam-BOO!"
  135. Data "What's a ghost's favorite dessert? I-Scream!"
  136. Data "Where do ghosts buy their food? At the ghost-ery store!"
  137. Data "How do you know when a ghost is sad? He starts boo hooing."
  138. Data "Why don't mummies take time off? They're afraid to unwind."
  139. Data "Why did the headless horseman go into business? He wanted to get ahead in life."
  140. Data "What kind of music do mummies like listening to on Halloween? Wrap music."
  141. Data "Why don't mummies have friends? Because they're too wrapped up in themselves."
  142. Data "Why did the vampire read the newspaper? He heard it had great circulation."
  143. Data "How do vampires get around on Halloween? On blood vessels."
  144. Data "What's it like to be kissed by a vampire? It's a pain in the neck."
  145. Data "What's it called when a vampire has trouble with his house? A grave problem."
  146. Data "How can you tell when a vampire has been in a bakery? All the jelly has been sucked out of the jelly doughnuts."
  147. Data "What do you get when you cross a vampire and a snowman? Frostbite."
  148. Data "Why do skeletons have low self-esteem? They have no body to love."
  149. Data "Know why skeletons are so calm? Because nothing gets under their skin."
  150. Data "What do you call a cleaning skeleton? The grim sweeper."
  151. Data "What do skeletons order at a restaurant? Spare ribs."
  152. Data "What do you call a witch's garage? A broom closet."
  153. Data "What kind of food would you find on a haunted beach? A sand-witch!"
  154. Data "What was the witch's favorite subject in school? Spelling."
  155. Data "What do you call two witches who live together? Broom-mates!"
  156. Data "What's a witch's favorite makeup? Ma-scare-a."
  157. Data "Who helps the little pumpkins cross the road safely? The crossing gourd."
  158. Data "What treat do eye doctors give out on Halloween? Candy corneas."
  159. Data "What type of plants do well on all Hallow's Eve? Bam-BOO!"
  160. Data "What do birds say on Halloween? Trick or tweet!"
  161. Data "Why don't skeletons ever go trick or treating? Because they have no-body to go with."
  162. Data "Where do ghosts buy their Halloween candy? At the ghost-ery store!"
  163. Data "What do owls say when they go trick or treating? 'Happy Owl-ween!'"
  164. Data "What do ghosts give out to trick or treaters? Booberries!"
  165. Data "Who did Frankenstein go trick or treating with? His ghoul friend."
  166. Data "What Halloween candy is never on time for the party? Choco-LATE!"
  167. Data "What do witches put on to go trick or treating? Mas-scare-a."
  168. Data "What does Bigfoot say when he asks for candy?  'Trick-or-feet!'"
  169. Data "Which type of pants do ghosts wear to trick or treat? Boo jeans."
  170. Data "What makes trick or treating with twin witches so challenging? You never know which witch is which!"
  171. Data "What happens when a vampire goes in the snow? Frost bite!"
  172. Data "What do you call two witches living together? Broommates"
  173. Data "What position does a ghost play in hockey? Ghoulie."
  174. Data "What do mummies listen to on Halloween? Wrap music."
  175. Data "How do you make a skeleton laugh? You tickle his funny bone!"
  176. Data "Which Halloween monster is good at math? Count Dracula!"
  177. Data "Why did the Cyclops give up teaching? He only had one pupil!"
  178. Data "Why didn't the skeleton go to see a scary movie? He didn't have the guts."
  179. Data "What did the boy ghost say to the girl ghost? 'You sure are boo-tiful!'"
  180. Data "Where does Dracula keep his money? In a blood bank."
  181. Data "Why are ghosts terrible liars? You can see right through them!"
  182. Data "Why don't mummies take vacations? They're afraid to unwind."
  183. Data "What is a vampire's favorite holiday, besides Halloween? Fangs-giving!"
  184. Data "Where do fashionable ghosts shop? Bootiques!"
  185. Data "What's a monster's favorite play? Romeo and Ghouliet!"
  186. Data "What room does a ghost not need? A living room."
  187. Data "What monster plays tricks on Halloween? Prank-enstein!"
  188. Data "What's a ghost's favorite dessert? I scream."
  189. Data "What does the skeleton chef say when he serves you a meal? 'Bone Appetit!'"
  190. Data "What is a vampire's favorite fruit? A neck-tarine!"
  191. Data "What do witches put on their bagels? Scream cheese."
  192. Data "What do ghosts eat for dinner? Spook-ghetti!"
  193. Data "What do skeletons order at restaurants? Spare ribs."
  194. Data "What does a panda ghost eat? Bam-BOO!"
  195. Data "What tops off a mummy's ice cream sundae? Whipped scream."
  196. Data "What's a ghost's favorite yogurt flavor? Boo-berry!"
  197. Data "What's a vampire's least favorite meal? A steak!"
  198. Data "Why was the candy corn booed off the stage? All of his jokes were too corny!"
  199. Data "EOD"
  200.  
  201. Sub DisplayScreen
  202.     Color 12, 8: Cls
  203.     cp 4, "*** Halloween Challenge - Cryptogram Puzzle ***"
  204.     Color 6
  205.     cp 6, "Solve puzzle by selecting a Code letter then selecting a Guess letter for it."
  206.     cp 7, "All selections are made by pressing spacebar when you see your letter or digit."
  207.     cp 8, "You will need to verify your selection by pressing spacebar again when see Y for Yes."
  208.     cp 9, "Use the escape key to quit immediately (an X box in top right is not accessible)."
  209.     Color 12
  210.     cp 11, "To get the answer and move onto next puzzle, select 1."
  211.     cp 12, "To decode current highlighted letter, select 2."
  212.     cp 13, "To solve a letter, select 3 and then select letter to find."
  213.     cp 14, "To clear a guess at highlighted Code letter, select 4."
  214.     Color 14
  215.     Locate 17, (120 - Len(Answer$)) / 2: Print Coded$
  216.     Color 15
  217.     Locate 18, (120 - Len(Answer$)) / 2
  218.     For i = 1 To Len(Answer$)
  219.         w$ = Mid$(Working$, i, 1): c$ = Mid$(Coded$, i, 1)
  220.         a$ = Mid$(Answer$, i, 1): h$ = Letters$(HighLited)
  221.         If w$ = "*" Then
  222.             pc$ = "*": If h$ = c$ Then Color 15, 9 Else Color 15, 8
  223.         Else
  224.             Color 15, 8: If w$ = UCase$(a$) Then pc$ = a$ Else pc$ = w$
  225.         End If
  226.         Print pc$;
  227.     Next
  228.     spaces = 9
  229.     For i = 1 To 26 'blue background highlighter
  230.         If i = HighLited Then Color 14, 9 Else Color 14, 8
  231.         Locate 21, spaces: Print Letters$(i)
  232.         If i = HighLited Then Color 14, 9 Else Color 15, 8
  233.         Locate 22, spaces: Print Guesses$(i)
  234.         spaces = spaces + 4
  235.     Next
  236.     If Mode = 1 Then
  237.         Color 15, 8
  238.         cp 24, "Guess Solve Letter or Menu #"
  239.     Else
  240.         Color 14, 8
  241.         cp 24, "Select Code Letter or Menu #"
  242.     End If
  243.  
  244. Sub cp (row, text$) ' center text on text screen
  245.     Locate row, 1: Print Space$(_Width) ' clear out old line in case the next is shorter
  246.     Locate row, (_Width - Len(text$)) / 2: Print text$
  247.  
  248. Function choice$ (row, col, selection$)
  249.     fg~& = _DefaultColor: bg~& = _BackgroundColor
  250.     saveRow = CsrLin: saveCol = Pos(0): t = Timer
  251.     GoSub show
  252.     Do
  253.         k$ = InKey$
  254.         If k$ = Chr$(27) Then System ' emergency exit
  255.         GoSub show:
  256.         If k$ = " " Then
  257.             t = Timer: place = (place + 1) Mod Len(selection$)
  258.         Else ' watch out for midnight!
  259.             If Timer - t > 4 Then choice$ = Mid$(selection$, place + 1, 1): Locate saveRow, saveCol: Exit Function
  260.         End If
  261.         _Limit 7 'so can hold down spacebar, nice
  262.     Loop
  263.     show:
  264.     Locate row, col
  265.     For i = 1 To Len(selection$)
  266.         If i = place + 1 Then Color bg~&, fg~& Else Color fg~&, bg~&
  267.         Locate row, col - 1 + i: Print Mid$(selection$, i, 1);
  268.     Next
  269.     Color fg~&, bg~&
  270.     Return
  271.  
  272.  

It's allot easier to play now! Thanks Steve

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #3 on: October 04, 2021, 05:09:47 pm »
I’d use _KEYDOWN or INP, over the other input methods like INKEY$, INPUT$, or _KEYHIT.  Reason being?  You don't need to worry over any keyboard buffers screwing things up with those!
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: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #4 on: October 04, 2021, 06:44:10 pm »
OK _KeyDown will replace InKey$ in next update. Seems to not get so carried away when holding down the Spacebar.

Thanks Steve!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #5 on: October 04, 2021, 06:46:57 pm »
Here is the replacement Function in case anyone can't wait to try out:
Code: QB64: [Select]
  1. Function choice$ (row, col, selection$) ' replace InKey$ with _KeyDown()
  2.     fg~& = _DefaultColor: bg~& = _BackgroundColor
  3.     saveRow = CsrLin: saveCol = Pos(0): t = Timer
  4.     GoSub show
  5.     Do
  6.         If _KeyDown(27) Then System ' emergency exit
  7.         GoSub show:
  8.         If _KeyDown(32) Then
  9.             t = Timer: place = (place + 1) Mod Len(selection$)
  10.         Else ' watch out for midnight!
  11.             If Timer - t > 4 Then choice$ = Mid$(selection$, place + 1, 1): Locate saveRow, saveCol: Exit Function
  12.         End If
  13.         _Limit 7 'so can hold down spacebar, nice
  14.     Loop
  15.     show:
  16.     Locate row, col
  17.     For i = 1 To Len(selection$)
  18.         If i = place + 1 Then Color bg~&, fg~& Else Color fg~&, bg~&
  19.         Locate row, col - 1 + i: Print Mid$(selection$, i, 1);
  20.     Next
  21.     Color fg~&, bg~&
  22.     Return
  23.  

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #6 on: October 06, 2021, 11:53:12 am »
I had real problem using _Keydown(32) for detecting the spacebar press. Sometimes it would not move at all on a press and sometimes it would jump 2 letters on a press.

I slept on problem and came up with theory: the polling for keypress at 5 times a sec (_Limit 5) is too course a polling, causing the misses or the 2 jumps. So I added an inner loop for polling with _Limit 200 and that seems to remove the erratic behavior and smooth out scrolling down a line of letters.

Here is the updated function:
Code: QB64: [Select]
  1. Function choice$ (row, col, selection$) ' replace InKey$ with _KeyDown()
  2.     fg~& = _DefaultColor: bg~& = _BackgroundColor
  3.     saveRow = CsrLin: saveCol = Pos(0): t = Timer
  4.     GoSub show
  5.     Do
  6.         If _KeyDown(27) Then System ' emergency exit
  7.         GoSub show:
  8.         ' 2021-10-06 fix for polling erratic behavior: misses or jumps, check for spacebar way more often
  9.         While Timer - t < 4 ' smooth out the jumpiness sometimes no response, sometimes jumps 2x' on one press????
  10.             If _KeyDown(27) Then System ' emergency exit
  11.             If _KeyDown(32) Then t = Timer: place = (place + 1) Mod Len(selection$): Exit While
  12.             _Limit 200 '<<<< fine tune the polling for spacebar!!!
  13.         Wend
  14.         If Timer - t >= 4 Then choice$ = Mid$(selection$, place + 1, 1): Locate saveRow, saveCol: Exit Function
  15.         _Limit 5 'so can hold down spacebar, nice
  16.     Loop
  17.     show:
  18.     Locate row, col
  19.     For i = 1 To Len(selection$)
  20.         If i = place + 1 Then Color bg~&, fg~& Else Color fg~&, bg~&
  21.         Locate row, col - 1 + i: Print Mid$(selection$, i, 1);
  22.     Next
  23.     _Display
  24.     Color fg~&, bg~&
  25.     Return
  26.  

Much smoother scroll action, way way less over scroll that Inkey$ would have. I think I have it just right now.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #7 on: October 06, 2021, 03:39:20 pm »
Very cool... Selection, as you rightly stated, requires a little practice... But still a cool game. Well done!

So... The xmas version... Will it be shades of red, white and green? Hmm...

You could start a series! There are SO many holidays!

Do you do requests? How about a version dedicated to the Hairy-nosed Wombat? Oh. What about the Emu or Red-backed Spider or the Platypus?

If you are "really" desperate for ideas, you can always fall back on, famous quotes; trivia etc... But seriously.... How can you turn down a Wombat?
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #8 on: October 07, 2021, 11:21:33 am »
Thanks @johnno56

Still have ways to go with graphics, how are the sounds coming?

I have worms almost done, ran into a some odd problems, a couple solved very late last night one stubborn one remains.
1. Using colors to poison worms, Point recognizes colors set by _RGB32 but apparently not &HFF.... ?

2. Blunder on my part where I clear WormYard (screen section worms are allowed) whenever I send Reset signal with default back color but later want to use image as background so clearing WormYard wipes out image. I see now that could be solved with two different values for reset as opposed to just Yes/No, T/F.

3. I switch to Full Screen Mode in second part of test and demo code and the worms insist on coming in at the old screen size. I think it is some sort of racing problem getting _Width and _Height reset when I run a WorkYard update. Something, it was so late with blurry eyes and mind...

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #9 on: October 07, 2021, 11:57:48 am »
@bplus there shouldn't be any issues with &HFF... colors.   Can you share some simplified code highlighting the issue you're speaking of?

The only issue I know you might run into with point and &HFF is of unspecified variable type incompatibility.

Red = &HFFFF0000.   Right??

Maybe not!   Is that value signed or unsigned?  Integer, or Single?  If Red is SINGLE, I doubt it'll match POINT values of _RGB32(255,0,0) as the variable value loses precision.  If RED is LONG, it's not going to match a _RGB32(255,0,0) POINT, as it'll be a negative value and the POINT is positive.

Try this, for instance:

SCREEN _NEWIMAGE(640,480,32)
PSET (0,0), -1&
PRINT -1&, POINT(0,0)

The -1& is a long value color.  The POINT is an unsigned long.  In hex, both would be &HFFFFFFFF, but in decimal mode they're -1 and (some big number).

If you're going to use POINT, make certain all colors are unsigned, or you may get issues in your code.

This includes using &HFFFFFFFF~& instead of just &HFFFFFFFF.   ;D
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: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #10 on: October 07, 2021, 12:06:45 pm »
Hi Steve,

I posted the code I was testing last night with another change that might solve racing problem with a delay before I call NewWormYard to get _Width and _Height updated ? (might be misdiagnosed problem but the extra delay seems to fix the last big bug I had last night.
see https://www.qb64.org/forum/index.php?topic=4266.msg136529#msg136529

As far as color and point goes, fixed when switched to _RGB32 instead og &HFF.... for colors ie,
Set poison boxes with &HFFFFFFFF or &HFFFFFF00 White and Yellow then compared POINT(x,y) to same &HFFFFFFFF or &HFFFFFF00 and no worky. Changed to _RGB32 both setting the boxes and then comparing Point returns to _RGB32 success!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #11 on: October 07, 2021, 12:15:13 pm »
Quote
This includes using &HFFFFFFFF~& instead of just &HFFFFFFFF.   ;D

Oh!! that's probably it then! I never think of the &H numbers as negative, where is the sign?! ;-))

Well there's an important practical lesson, thanks! @SMcNeill

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #12 on: October 07, 2021, 09:45:03 pm »
OK DrawWorms installed into Crypt-O-Gram Puzzle, how good are you working with distractions? Moo ha ha

v2021-10-07
Code: QB64: [Select]
  1. _Title "Halloween Challenge: Crypt-O-Gram Puzzle" ' b+  started One Key Challenge 2021-09-25
  2. ' from One Key Challenge - Cryptogram Puzzle   2021-10-02
  3.  
  4. ' 2021-09-07 Jokes are intended for QB64 home programming entertainment use only.
  5. ' Thank you CountryLiving 1-33
  6. ' https://www.countryliving.com/entertaining/a32963261/halloween-jokes/
  7. ' Thank you GoodHousekeeping 34-72
  8. ' https://www.goodhousekeeping.com/holidays/halloween-ideas/a32998753/halloween-jokes/
  9.  
  10. ' 2021-10-03 install new set of jokes and new Binary Select Input Algorithm
  11. ' Redo Mode system to fix differences of input methods.
  12. ' Recolor green background has me seeing Red!
  13.  
  14. ' 2021-10-04 Steve McNeill came up with an easier to understand and use input system.
  15. ' Installing new Function and updating Game. Steve also told me how to change color palette,
  16. ' now we have some real Orange! for #12 meant for high red.
  17.  
  18. ' Next version: Follow Steve's advice to use _KeyDown in stead of InKey$
  19. ' Improved Choice to reduce no response to keypress or double jumping.
  20. ' v 2021-10-07 install DrawWorms subroutines and get working.
  21.  
  22. 'Fall letters and background
  23. Const Orange = &HFFFF8800 ' 12 d
  24. Const White = &HFFFFFFFF ' 15 d
  25. Const Back = &HFF302010 ' 8 ? d
  26. Const Red = &HFFFF2222 ' print under title
  27. Const Yellow = &HFFFFFF00 ' 14 d
  28. Const Blue = &HFF0000FF ' 9 light blue
  29. Const BB = &HFF33BB33 ' 6 blue brown ?
  30. Const Xmax = 120 * 8 ' started with text screen _width 120, 30
  31. Const Ymax = 30 * 16
  32.  
  33. 'for Graphic effects
  34. Const nWorms = 30
  35.  
  36. 'for graphics effects
  37. Type Object
  38.     X As Single ' usu top left corner   could be center depending on object
  39.     Y As Single ' ditto
  40.     W As Single ' width   or maybe radius
  41.     H As Single ' height
  42.     DX As Single ' moving opjects
  43.     DY As Single ' ditto
  44.     DIR As Single ' short for direction or heading usu a radian angle
  45.     Sz As Single ' perhaps a scaling factor
  46.     Act As Integer ' lives countdown or just plain ACTive TF
  47.     C1 As _Unsigned Long ' a foreground color
  48.     C2 As _Unsigned Long ' a background or 2nd color     OR C1 to c2 Range?
  49.  
  50. Screen _NewImage(Xmax, Ymax, 32)
  51. Randomize Timer ': Width 120, 30
  52.  
  53. Dim Shared Answer$ '  beginning phrase to be guessed    '   3 stages of the Puzzle
  54. Dim Shared Coded$ '   hidden in code
  55. Dim Shared Working$ ' decoded and solved when working$ becomes = ucase$(answer$)
  56. Dim Shared Letters$(1 To 26) ' for coding and highlited letters
  57. Dim Shared LCodes$(1 To 26) '  for code and decode by number 1 to 26
  58. Dim Shared Guesses$(1 To 26) ' track all the guess to decode
  59. Dim Shared HighLited ' cursor over letters to guess
  60. Dim Shared Mode
  61.  
  62. ' adding graphics effects
  63. Dim Shared Worms(1 To nWorms) As Object
  64. Dim Shared WormYard As Object
  65.  
  66. _FullScreen 'I guess it does make it easier to tell E from F...
  67.  
  68. Dim jokes$(1 To 100) ' load jokes one time from data statements in program
  69. For i = 1 To 100
  70.     Read r$
  71.     If r$ <> "EOD" Then jokes$(i) = r$: jCount = jCount + 1 Else Exit For
  72.  
  73. restart:
  74.  
  75. 'setup Puzzle and code it
  76. Answer$ = jokes$(Int(Rnd * jCount) + 1)
  77. For i = 1 To 26: Guesses$(i) = "-": Next 'setup the display guesses array
  78. For i = 1 To 26 ' use letters for display of letters to pick second and to create a code
  79.     Letters$(i) = Chr$(i + 64)
  80.     LCodes$(i) = Letters$(i) ' these will convert between each other by index number
  81. For i = 26 To 2 Step -1 ' shuffle the letters in LCode$()
  82.     Swap LCodes$(i), LCodes$(Int(Rnd * i) + 1)
  83. Coded$ = "": Working$ = "" ' reset for next go around
  84. For i = 1 To Len(Answer$) 'third: put the phrase in coded$ and hide it in working$
  85.     a = Asc(UCase$(Answer$), i)
  86.     If a >= 65 And a <= 90 Then
  87.         Coded$ = Coded$ + LCodes$(a - 64)
  88.         Working$ = Working$ + "*"
  89.     Else
  90.         Coded$ = Coded$ + Mid$(Answer$, i, 1)
  91.         Working$ = Working$ + Mid$(Answer$, i, 1)
  92.     End If
  93.  
  94. HighLited = 1 'setup done start game
  95. Mode = 0
  96.  
  97. 'select a grahics effect  on timer
  98. GE = 1 ' <<< convert to pick at random from N effects
  99. nTimer% = _FreeTimer
  100. If GE = 1 Then
  101.     NewWormYard 0, 0, _Width, _Height
  102.     resetWorms% = -1
  103.     DrawWorms resetWorms% ' get draw worms started on a new set o worms
  104.     resetWorms% = 0 ' dont reset while running on timer
  105.     On Timer(0.5) DrawWorms resetWorms%
  106.     Timer On
  107.  
  108. DisplayInstructions '<< this part can be eaten by worms
  109. Update ' this part is critical to continue work on puzzle
  110.     DrawWorms resetWorms
  111.     k$ = choice$(25, 44, " 1234ABCDEFGHIJKLMNOPQRSTUVWXYZ")
  112.     If k$ <> " " Then
  113.         If Mode = 0 Then ' highlight a letter
  114.             'm replaces arrows and mouse select of highlited 1 to 26 for letters
  115.             test = InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", k$)
  116.             If test > 0 Then
  117.                 HighLited = test
  118.                 Mode = 1
  119.             Else
  120.                 test = InStr("1234", k$)
  121.                 If test > 0 Then
  122.                     Select Case test
  123.                         Case 1: GoSub do1
  124.                         Case 2: GoSub do2
  125.                         Case 3: GoSub do3
  126.                         Case 4: GoSub do4
  127.                     End Select
  128.                 Else
  129.                     Mode = 0
  130.                 End If
  131.             End If
  132.         Else
  133.             Select Case k$
  134.                 Case "1": GoSub do1
  135.                 Case "2": GoSub do2
  136.                 Case "3": GoSub do3
  137.                 Case "4": GoSub do4
  138.                 Case "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"
  139.                     Guesses$(HighLited) = k$ ' for screen updates
  140.                     For i = 1 To Len(Working$)
  141.                         If Letters$(HighLited) = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = k$
  142.                     Next
  143.                     Mode = 0
  144.             End Select
  145.         End If
  146.     End If
  147.     Update
  148.     _Limit 60
  149. Loop Until Working$ = UCase$(Answer$)
  150. Update
  151. Color Orange, Back
  152. cp 19, "You got it!    5 secs to next puzzle..."
  153. GoTo restart
  154.  
  155. do1: ' display answer
  156. Working$ = UCase$(Answer$) ' show the answer$ guesses correct moves to next puzzle
  157. Mode = 0
  158. Update
  159.  
  160. do2: ' get decode letter for highlighted Letter
  161. For i = 1 To 26
  162.     If LCodes$(i) = Letters$(HighLited) Then c$ = Chr$(i + 64): Exit For
  163. Guesses$(HighLited) = c$ ' for screen updates
  164. For i = 1 To Len(Working$)
  165.     If Letters$(HighLited) = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = c$
  166. Update
  167. Mode = 0
  168.  
  169. do3: ' find a uncoded letter
  170. Color White, Back
  171. cp 24, "     Select Letter to Find     "
  172. Locate 25, 1: Print Space$(100); ' clear out old line
  173. d$ = choice$(25, 46, " ABCDEFGHIJKLMNOPQRSTUVWXYZ")
  174. If d$ <> " " Then
  175.     c$ = LCodes$(Asc(d$) - 64)
  176.     Guesses$(Asc(c$) - 64) = d$
  177.     For i = 1 To Len(Working$)
  178.         If c$ = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = d$
  179.     Next
  180.     Mode = 0
  181.     Update
  182.  
  183. do4: ' clear guess letter from code letter
  184. Guesses$(HighLited) = "-"
  185. For i = 1 To Len(Working$)
  186.     If Letters$(HighLited) = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = "*" ' clear the letter
  187. Mode = 0
  188. Update
  189.  
  190. 'one liners
  191. Data "Why do ghosts go on diets? So they can keep their ghoulish figures"
  192. Data "Where does a ghost go on vacation? Mali-boo."
  193. Data "Why did the ghost go into the bar? For the Boos."
  194. Data "What is in a ghost's nose? Boo-gers."
  195. Data "Why did the policeman ticket the ghost on Halloween? It didn't have a haunting license."
  196. Data "Why do demons and ghouls hang out together? Because demons are a ghoul's best friend!"
  197. Data "Why did the ghost starch his sheet? He wanted everyone scared stiff."
  198. Data "What does a panda ghost eat? Bam-BOO!"
  199. Data "What's a ghost's favorite dessert? I-Scream!"
  200. Data "Where do ghosts buy their food? At the ghost-ery store!"
  201. Data "How do you know when a ghost is sad? He starts boo hooing."
  202. Data "Why don't mummies take time off? They're afraid to unwind."
  203. Data "Why did the headless horseman go into business? He wanted to get ahead in life."
  204. Data "What kind of music do mummies like listening to on Halloween? Wrap music."
  205. Data "Why don't mummies have friends? Because they're too wrapped up in themselves."
  206. Data "Why did the vampire read the newspaper? He heard it had great circulation."
  207. Data "How do vampires get around on Halloween? On blood vessels."
  208. Data "What's it like to be kissed by a vampire? It's a pain in the neck."
  209. Data "What's it called when a vampire has trouble with his house? A grave problem."
  210. Data "How can you tell when a vampire has been in a bakery? All the jelly has been sucked out of the jelly doughnuts."
  211. Data "What do you get when you cross a vampire and a snowman? Frostbite."
  212. Data "Why do skeletons have low self-esteem? They have no body to love."
  213. Data "Know why skeletons are so calm? Because nothing gets under their skin."
  214. Data "What do you call a cleaning skeleton? The grim sweeper."
  215. Data "What do skeletons order at a restaurant? Spare ribs."
  216. Data "What do you call a witch's garage? A broom closet."
  217. Data "What kind of food would you find on a haunted beach? A sand-witch!"
  218. Data "What was the witch's favorite subject in school? Spelling."
  219. Data "What do you call two witches who live together? Broom-mates!"
  220. Data "What's a witch's favorite makeup? Ma-scare-a."
  221. Data "Who helps the little pumpkins cross the road safely? The crossing gourd."
  222. Data "What treat do eye doctors give out on Halloween? Candy corneas."
  223. Data "What type of plants do well on all Hallow's Eve? Bam-BOO!"
  224. Data "What do birds say on Halloween? Trick or tweet!"
  225. Data "Why don't skeletons ever go trick or treating? Because they have no-body to go with."
  226. Data "Where do ghosts buy their Halloween candy? At the ghost-ery store!"
  227. Data "What do owls say when they go trick or treating? 'Happy Owl-ween!'"
  228. Data "What do ghosts give out to trick or treaters? Booberries!"
  229. Data "Who did Frankenstein go trick or treating with? His ghoul friend."
  230. Data "What Halloween candy is never on time for the party? Choco-LATE!"
  231. Data "What do witches put on to go trick or treating? Mas-scare-a."
  232. Data "What does Bigfoot say when he asks for candy?  'Trick-or-feet!'"
  233. Data "Which type of pants do ghosts wear to trick or treat? Boo jeans."
  234. Data "What makes trick or treating with twin witches so challenging? You never know which witch is which!"
  235. Data "What happens when a vampire goes in the snow? Frost bite!"
  236. Data "What do you call two witches living together? Broommates"
  237. Data "What position does a ghost play in hockey? Ghoulie."
  238. Data "What do mummies listen to on Halloween? Wrap music."
  239. Data "How do you make a skeleton laugh? You tickle his funny bone!"
  240. Data "Which Halloween monster is good at math? Count Dracula!"
  241. Data "Why did the Cyclops give up teaching? He only had one pupil!"
  242. Data "Why didn't the skeleton go to see a scary movie? He didn't have the guts."
  243. Data "What did the boy ghost say to the girl ghost? 'You sure are boo-tiful!'"
  244. Data "Where does Dracula keep his money? In a blood bank."
  245. Data "Why are ghosts terrible liars? You can see right through them!"
  246. Data "Why don't mummies take vacations? They're afraid to unwind."
  247. Data "What is a vampire's favorite holiday, besides Halloween? Fangs-giving!"
  248. Data "Where do fashionable ghosts shop? Bootiques!"
  249. Data "What's a monster's favorite play? Romeo and Ghouliet!"
  250. Data "What room does a ghost not need? A living room."
  251. Data "What monster plays tricks on Halloween? Prank-enstein!"
  252. Data "What's a ghost's favorite dessert? I scream."
  253. Data "What does the skeleton chef say when he serves you a meal? 'Bone Appetit!'"
  254. Data "What is a vampire's favorite fruit? A neck-tarine!"
  255. Data "What do witches put on their bagels? Scream cheese."
  256. Data "What do ghosts eat for dinner? Spook-ghetti!"
  257. Data "What do skeletons order at restaurants? Spare ribs."
  258. Data "What does a panda ghost eat? Bam-BOO!"
  259. Data "What tops off a mummy's ice cream sundae? Whipped scream."
  260. Data "What's a ghost's favorite yogurt flavor? Boo-berry!"
  261. Data "What's a vampire's least favorite meal? A steak!"
  262. Data "Why was the candy corn booed off the stage? All of his jokes were too corny!"
  263. Data "EOD"
  264.  
  265. Sub Update ' preserve from ravages of graphics effects ;-))
  266.     Color Yellow
  267.     Locate 17, (120 - Len(Answer$)) / 2: Print Coded$;
  268.     Color White
  269.     Locate 18, (120 - Len(Answer$)) / 2
  270.     For i = 1 To Len(Answer$)
  271.         w$ = Mid$(Working$, i, 1): c$ = Mid$(Coded$, i, 1)
  272.         a$ = Mid$(Answer$, i, 1): h$ = Letters$(HighLited)
  273.         If w$ = "*" Then
  274.             pc$ = "*": If h$ = c$ Then Color White, Blue Else Color White, Back
  275.         Else
  276.             Color White, Back: If w$ = UCase$(a$) Then pc$ = a$ Else pc$ = w$
  277.         End If
  278.         Print pc$;
  279.     Next
  280.     spaces = 9
  281.     For i = 1 To 26 'blue background highlighter
  282.         If i = HighLited Then Color Yellow, Blue Else Color Yellow, Back
  283.         Locate 21, spaces: Print Letters$(i);
  284.         If i = HighLited Then Color Yellow, Blue Else Color White, Back
  285.         Locate 22, spaces: Print Guesses$(i);
  286.         spaces = spaces + 4
  287.     Next
  288.     If Mode = 1 Then
  289.         Color White, Back
  290.         cp 24, "  Guess Solve Letter or Menu # "
  291.     Else
  292.         Color Yellow, Back
  293.         cp 24, "  Select Code Letter or Menu # "
  294.     End If
  295.     _Display
  296.  
  297. Sub DisplayInstructions ' only once let worms eat them up as game goes on
  298.     Color Orange, Back: Cls
  299.     cp 4, "*** Halloween Challenge - Crypt-O-Gram Puzzle ***"
  300.     Color Red
  301.     cp 6, "Solve puzzle by selecting a Code letter then selecting a Guess letter for it."
  302.     cp 7, "All selections are made by pressing spacebar when you see your letter or digit."
  303.     cp 8, "You will need to verify your selection by pressing spacebar again when see Y for Yes."
  304.     cp 9, "Use the escape key to quit immediately (an X box in top right is not accessible)."
  305.     Color BB
  306.     cp 11, "To get the answer and move onto next puzzle, select 1."
  307.     cp 12, "To decode current highlighted letter, select 2."
  308.     cp 13, "To solve a letter, select 3 and then select letter to find."
  309.     cp 14, "To clear a guess at highlighted Code letter, select 4."
  310.     _Display
  311.  
  312. Sub cp (row, text$) ' center text on text screen
  313.     'Locate row, 1: Print Space$(_Width) ' clear out old line in case the next is shorter
  314.     'Locate row, 1: Print Space$(Xmax / 8);  'text screen
  315.     ' clear old line was interferring with worm trails
  316.     Locate row, (Xmax / 8 - Len(text$)) / 2: Print text$;
  317.  
  318. Function choice$ (row, col, selection$) ' replace InKey$ with _KeyDown()
  319.     fg~& = _DefaultColor: bg~& = _BackgroundColor
  320.     saveRow = CsrLin: saveCol = Pos(0): t = Timer
  321.     GoSub show
  322.     Do
  323.         If _KeyDown(27) Then System ' emergency exit
  324.         GoSub show:
  325.         ' 2021-10-06 fix for polling erratic behavior: misses or jumps, check for spacebar way more often
  326.         While Timer - t < 4 ' smooth out the jumpiness sometimes no response, sometimes jumps 2x' on one press????
  327.             If _KeyDown(27) Then System ' emergency exit
  328.             If _KeyDown(32) Then t = Timer: place = (place + 1) Mod Len(selection$): Exit While
  329.             _Limit 200 '<<<< fine tune the polling for spacebar!!!
  330.         Wend
  331.         If Timer - t >= 4 Then choice$ = Mid$(selection$, place + 1, 1): Locate saveRow, saveCol: Exit Function
  332.         _Limit 5 'so can hold down spacebar, nice
  333.     Loop
  334.     show:
  335.     Locate row, col
  336.     For i = 1 To Len(selection$)
  337.         If i = place + 1 Then Color bg~&, fg~& Else Color fg~&, bg~&
  338.         Locate row, col - 1 + i: Print Mid$(selection$, i, 1);
  339.     Next
  340.     _Display
  341.     Color fg~&, bg~&
  342.     Return
  343.  
  344. Sub DrawWorms (DrawReset As Integer) ' one frame in main loop
  345.     Static x(1 To nWorms, 1 To 20), y(1 To nWorms, 1 To 20)
  346.     If DrawReset Then
  347.         For i = 1 To nWorms
  348.             NewWorm i
  349.             For j = 1 To 20
  350.                 x(i, j) = 0: y(i, j) = 0
  351.             Next
  352.         Next
  353.         DrawReset = 0
  354.     End If
  355.     For i = 1 To nWorms
  356.         Fcirc Worms(i).X, Worms(i).Y, 8, &HFF000000 ' fix 2021-10-07 to prevent program hangs
  357.         If _KeyDown(27) Then Exit Sub
  358.         For j = 1 To Worms(i).Sz ' blackout old segments
  359.             If x(i, j) And y(i, j) Then Fcirc x(i, j), y(i, j), 8, &HFF000000
  360.         Next
  361.         tryAgain:
  362.         If _KeyDown(27) Then Exit Sub
  363.         If Rnd < .3 Then Worms(i).DX = Worms(i).DX + .8 * Rnd - .4 Else Worms(i).DY = Worms(i).DY + .8 * Rnd - .4
  364.         If Abs(Worms(i).DX) > 2 Then Worms(i).DX = Worms(i).DX * .5
  365.         If Abs(Worms(i).DY) > 2 Then Worms(i).DY = Worms(i).DY * .5
  366.         x = Worms(i).X + Worms(i).DX * 2.0: y = Worms(i).Y + Worms(i).DY * 2.0
  367.         good = -1
  368.         If x >= WormYard.X + 6 And x <= WormYard.X + WormYard.W - 6 Then
  369.             If y >= WormYard.Y + 6 And y <= WormYard.Y + WormYard.H - 6 Then
  370.                 For yy = y - 6 To y + 6
  371.                     For xx = x - 6 To x + 6
  372.                         If Point(xx, yy) = _RGB32(255, 255, 255) Or Point(xx, yy) = _RGB32(255, 255, 0) Then good = 0: Exit For
  373.                     Next
  374.                     If good = 0 Then Exit For
  375.                 Next
  376.             Else
  377.                 good = 0
  378.             End If
  379.         Else
  380.             good = 0
  381.         End If
  382.         If good = 0 Then 'turn the worm
  383.             'Beep: Locate 1, 1: Print x, y
  384.             'Input "enter >", w$
  385.             If Rnd > .5 Then 'change dx
  386.                 If Worms(i).DX Then
  387.                     Worms(i).DX = -Worms(i).DX
  388.                 Else
  389.                     If Rnd > .5 Then Worms(i).DX = 1 Else Worms(i).DX = -1
  390.                 End If
  391.             Else
  392.                 If Worms(i).DY Then
  393.                     Worms(i).DY = -Worms(i).DY
  394.                 Else
  395.                     If Rnd > .5 Then Worms(i).DY = 1 Else Worms(i).DY = -1
  396.                 End If
  397.             End If
  398.             GoTo tryAgain
  399.         End If
  400.         For j = Worms(i).Sz To 2 Step -1
  401.             x(i, j) = x(i, j - 1): y(i, j) = y(i, j - 1)
  402.             If x(i, j) And y(i, j) Then DrawBall x(i, j), y(i, j), 6, Worms(i).C1
  403.         Next
  404.         x(i, 1) = x: y(i, 1) = y
  405.         DrawBall x(i, 1), y(i, 1), 6, Worms(i).C1
  406.         Worms(i).X = x: Worms(i).Y = y
  407.     Next i 'worm index
  408.     _Display
  409.  
  410. Sub NewWormYard (x, y, w, h)
  411.     WormYard.X = x: WormYard.Y = y: WormYard.W = w: WormYard.H = h
  412.     For i = 1 To nWorms
  413.         NewWorm i
  414.     Next
  415.  
  416. Sub NewWorm (i)
  417.     'pick which side to enter, for dx, dy generally headed towards inner screen
  418.     side = Int(Rnd * 4)
  419.     Select Case side
  420.         Case 0 ' left side
  421.             Worms(i).X = WormYard.X + 6
  422.             Worms(i).Y = WormYard.Y + 6 + (WormYard.H - 12) * Rnd
  423.             Worms(i).DX = 1
  424.             Worms(i).DY = 0
  425.         Case 1 'right side
  426.             Worms(i).X = WormYard.X + WormYard.W - 6
  427.             Worms(i).Y = WormYard.Y + 6 + (WormYard.H - 12) * Rnd
  428.             Worms(i).DX = -1
  429.             Worms(i).DY = 0
  430.         Case 2 ' top
  431.             Worms(i).Y = WormYard.Y + 6
  432.             Worms(i).X = WormYard.X + 6 + (WormYard.W - 12) * Rnd
  433.             Worms(i).DX = 0
  434.             Worms(i).DY = 1
  435.         Case 3 'bottom
  436.             Worms(i).Y = WormYard.Y + WormYard.H - 6
  437.             Worms(i).X = WormYard.X + 6 + (WormYard.W - 12) * Rnd
  438.             Worms(i).DX = 0
  439.             Worms(i).DY = -1
  440.     End Select
  441.     Worms(i).Sz = Int(Rnd * 11) + 10
  442.     side = Int(Rnd * 4): lev = Int(Rnd * 10)
  443.     If side = 0 Then
  444.         Worms(i).C1 = _RGB32(255 - 20 * lev + 50, 180 - 15 * lev, 180 - 15 * lev)
  445.     ElseIf side = 1 Then
  446.         Worms(i).C1 = _RGB32(255 - 20 * lev, 180 - 15 * lev + 50, 180 - 15 * lev)
  447.     ElseIf side = 2 Then
  448.         Worms(i).C1 = _RGB32(255 - 20 * lev, 180 - 15 * lev, 180 - 15 * lev + 20)
  449.     ElseIf side = 3 Then
  450.         Worms(i).C1 = _RGB32(255 - 20 * lev, 180 - 15 * lev, 180 - 15 * lev)
  451.     End If
  452.  
  453. Sub Fcirc (CX As Long, CY As Long, R As Long, C As _Unsigned Long)
  454.     Dim Radius As Long, RadiusError As Long
  455.     Dim X As Long, Y As Long
  456.     Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0
  457.     If Radius = 0 Then PSet (CX, CY), C: Exit Sub
  458.     Line (CX - X, CY)-(CX + X, CY), C, BF
  459.     While X > Y
  460.         RadiusError = RadiusError + Y * 2 + 1
  461.         If RadiusError >= 0 Then
  462.             If X <> Y + 1 Then
  463.                 Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  464.                 Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  465.             End If
  466.             X = X - 1
  467.             RadiusError = RadiusError - X * 2
  468.         End If
  469.         Y = Y + 1
  470.         Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  471.         Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  472.     Wend
  473.  
  474. Sub DrawBall (x, y, r, c As _Unsigned Long)
  475.     Dim rred As Long, grn As Long, blu As Long, rr As Long, f
  476.     rred = _Red32(c): grn = _Green32(c): blu = _Blue32(c)
  477.     For rr = r To 0 Step -1
  478.         f = 1.25 - rr / r
  479.         Fcirc x, y, rr, _RGB32(rred * f, grn * f, blu * f)
  480.     Next
  481.  


Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #13 on: October 08, 2021, 07:14:51 am »
The GoSub routine do3: was clearing a line across the screen which cut into the worm trails looking funky. Here is the fix for do3:
Code: QB64: [Select]
  1. do3: ' find a uncoded letter
  2. Color White, Back
  3. cp 24, "     Select Letter to Find     "
  4. Locate 25, 44: Print Space$(31); ' clear out old line
  5. d$ = choice$(25, 46, " ABCDEFGHIJKLMNOPQRSTUVWXYZ")
  6. If d$ <> " " Then
  7.     c$ = LCodes$(Asc(d$) - 64)
  8.     Guesses$(Asc(c$) - 64) = d$
  9.     For i = 1 To Len(Working$)
  10.         If c$ = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = d$
  11.     Next
  12.     Mode = 0
  13.     Update
  14.  

This just clears the exact text length that needed clearing, instead of the whole line.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #14 on: October 08, 2021, 10:10:38 am »
I am testing single word comments. Seems to be a little easier to understand. Give them a try.... If you can think of any others just let me know.

 
Logic is the beginning of wisdom.