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

0 Members and 1 Guest are viewing this topic.

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #15 on: October 08, 2021, 06:18:02 pm »
Let's go Brandon!

I wonder what that would dcryptify to?

Okay, neat looking screen presentation and I have to admit, the "Demons are a ghoul's best friend made me chuckle. Hey, didn't Steve have some word game in the works for this challenge? What was it called again, The Alphabator? You keep pulling letters and... Never mind.

Hey Mark, you could marry that to POWERSHELL and get the computer to give the answer over the speaker. Text to Speech is a nice feature. Just a thought.

    t
Pe e
   ^ (Word bump this!)
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: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #16 on: October 08, 2021, 09:51:37 pm »
Quote
"Demons are a ghoul's best friend

@Pete oh ha! I thought you were talking about @johnno56 comments, that's a joke I haven't gotten to yet!
Nice idea of using speech to text, I can and have done that in for windows apps. I had an app, "Henny pecked", that told one-liners Henny Youngman style, actually allot of Steve Write jokes.

Yeah @johnno56 take a break on the sounds, letters and selections probably will get boring, I think I have some Halloween music and sound effects might be better. (PS those words were not so clear to me, letters and multiple words seemed better to me?)

When trying to add spiders to graphics effects I had a hell of a time with multiple timers basically wasted the morning.

2 steps forward one back, I rewrote Choice$ function again! This time to use the main Loop and no extracurricular excursions into indy loops. It is actually working really sweet making input go much smoother. Now with some adjustments I can add effects much easier without timers.

Here is spiders added to worms with new Choice$ and allot of other rework.
v2021-10-08
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. ' v 2021-10-08: fix do3, blanking whole line or nearly, it disturbs worm trails.
  23. ' Add a spider screen for overlaying spiders wo changing the background.
  24. ' Man this is so screwed up... I'm taking another approach.
  25. ' ... rewrites and tests
  26. ' Now do3 completely rewritten as mode 3 along with Choice$ function
  27. ' Much better!! rewrote the way Choice works, no time consuming loops outside main loop,
  28. ' so no delaysin graphics effects so no need for timers. Only one side screen needed
  29. ' for tracking Worm Trails. Had to slow worms and Spider dowm for a _Limit 30 for everything.
  30.  
  31.  
  32. 'Fall letters and background
  33. Const Orange = &HFFFF8800 ' 12 d
  34. Const Back = &HFF302010 ' 8 ? d
  35. Const Red = &HFFFF2222 ' print under title
  36. Const Blue = &HFF0000FF ' 9 light blue
  37. Const BB = &HFF33BB33 ' 6 blue brown ?
  38. Const Xmax = 120 * 8 ' started with text screen _width 120, 30
  39. Const Ymax = 30 * 16
  40.  
  41. 'for Graphic effects
  42. Const nWorms = 30
  43. Const nSpiders = 15
  44.  
  45. 'for graphics effects
  46. Type Object
  47.     X As Single ' usu top left corner   could be center depending on object
  48.     Y As Single ' ditto
  49.     W As Single ' width   or maybe radius
  50.     H As Single ' height
  51.     DX As Single ' moving opjects
  52.     DY As Single ' ditto
  53.     DIR As Single ' short for direction or heading usu a radian angle
  54.     Sz As Single ' perhaps a scaling factor
  55.     Act As Integer ' lives countdown or just plain ACTive TF
  56.     C1 As _Unsigned Long ' a foreground color
  57.     C2 As _Unsigned Long ' a background or 2nd color     OR C1 to c2 Range?
  58. Dim Shared As _Unsigned Long White, Yellow
  59. White = _RGB32(255, 255, 255): Yellow = _RGB32(255, 255, 0) ' I give up, yellow and white aren't stopping the worms
  60. Dim Shared Answer$ '  beginning phrase to be guessed    '   3 stages of the Puzzle
  61. Dim Shared Coded$ '   hidden in code
  62. Dim Shared Working$ ' decoded and solved when working$ becomes = ucase$(answer$)
  63. Dim Shared Letters$(1 To 26) ' for coding and highlited letters
  64. Dim Shared LCodes$(1 To 26) '  for code and decode by number 1 to 26
  65. Dim Shared Guesses$(1 To 26) ' track all the guess to decode
  66. Dim Shared HighLited ' cursor over letters to guess
  67. Dim Shared Mode ' what are we getting a coded letter =0, a guess for that letter =1, a letter to find and decode=3
  68. Dim Shared KeyTimer
  69. Dim Shared Place
  70.  
  71. ' adding graphics effects
  72. ReDim Shared Worms(1 To nWorms) As Object
  73. Dim Shared WormYard As Object
  74. ReDim Shared S(1 To nSpiders) As Object ' Spider 0 is a spinner?
  75. Dim Shared WT As Long ' worm screen to track Worm Trails
  76.  
  77. ' main declares
  78. Dim jokes$(1 To 100) ' load jokes one time from data statements in program
  79. Dim As Integer i, resetWorms, si, jCount, a, lc, test
  80. Dim r$, k$, c$
  81.  
  82. Screen _NewImage(Xmax, Ymax, 32)
  83. Randomize Timer ': Width 120, 30 converted to graphics screen
  84. _FullScreen 'I guess it does make it easier to tell E from F...
  85.  
  86. WS = _NewImage(Xmax, Ymax, 32)
  87. For i = 1 To 100 'ready jokes
  88.     Read r$
  89.     If r$ <> "EOD" Then jokes$(i) = r$: jCount = jCount + 1 Else Exit For
  90. restart:
  91.  
  92. 'setup Puzzle and code it
  93. Answer$ = jokes$(Int(Rnd * jCount) + 1)
  94. For i = 1 To 26: Guesses$(i) = "-": Next 'setup the display guesses array
  95. For i = 1 To 26 ' use letters for display of letters to pick second and to create a code
  96.     Letters$(i) = Chr$(i + 64)
  97.     LCodes$(i) = Letters$(i) ' these will convert between each other by index number
  98. For i = 26 To 2 Step -1 ' shuffle the letters in LCode$()
  99.     Swap LCodes$(i), LCodes$(Int(Rnd * i) + 1)
  100. Coded$ = "": Working$ = "" ' reset for next go around
  101. For i = 1 To Len(Answer$) 'third: put the phrase in coded$ and hide it in working$
  102.     a = Asc(UCase$(Answer$), i)
  103.     If a >= 65 And a <= 90 Then
  104.         Coded$ = Coded$ + LCodes$(a - 64)
  105.         Working$ = Working$ + "*"
  106.     Else
  107.         Coded$ = Coded$ + Mid$(Answer$, i, 1)
  108.         Working$ = Working$ + Mid$(Answer$, i, 1)
  109.     End If
  110. If WT Then _FreeImage WT ' clear WormTrails for new game
  111. WT = _NewImage(Xmax, Ymax, 32)
  112. ReDim Worms(1 To nWorms) As Object ' clear old arrays
  113. NewWormYard 0, 0, Xmax, Ymax
  114. resetWorms = -1
  115. ReDim S(1 To nSpiders) As Object
  116. si = 0: lc = 0
  117. HighLited = 1 'setup done start game
  118. Mode = 0
  119.  
  120. KeyTimer = Timer
  121.     Color , Back: Cls
  122.     DisplayInstructions '<< this part can be eaten by worms very bottom of drawing
  123.     _PutImage , WT, 0 ' the worm trails
  124.     Update ' need yellow and white to slow worms
  125.     DrawWorms resetWorms ' yellow and white not working???
  126.     lc = lc + 1
  127.     If lc Mod 300 = 299 Then 'drawSpiders
  128.         If si < nSpiders Then si = si + 1: newSpinner si
  129.     End If
  130.     For i = 1 To si
  131.         drawSpinner S(i).X, S(i).Y, S(i).Sz, _Atan2(S(i).DY, S(i).DX), S(i).C1
  132.         S(i).X = S(i).X + S(i).DX: S(i).Y = S(i).Y + S(i).DY
  133.         If S(i).X < -100 Or S(i).X > Xmax + 100 Or S(i).Y < -100 Or S(i).Y > Ymax + 100 Then newSpinner i
  134.     Next
  135.     'Update ' on top of every thing sets color to mode
  136.     If Mode = 3 Then
  137.         k$ = choice$(25, 33, " 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 ")
  138.     Else
  139.         k$ = choice$(25, 29, " 1 2 3 4 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 ")
  140.     End If
  141.     If k$ <> "" And k$ <> " " Then
  142.         If Mode = 0 Then ' highlight a letter
  143.             'm replaces arrows and mouse select of highlited 1 to 26 for letters
  144.             test = InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", k$)
  145.             If test > 0 Then
  146.                 HighLited = test
  147.                 Mode = 1
  148.             Else
  149.                 test = InStr("1234", k$)
  150.                 If test > 0 Then
  151.                     Select Case test
  152.                         Case 1: GoSub do1
  153.                         Case 2: GoSub do2
  154.                         Case 3: Mode = 3
  155.                         Case 4: GoSub do4
  156.                     End Select
  157.                 Else
  158.                     Mode = 0
  159.                 End If
  160.             End If
  161.         ElseIf Mode = 1 Then
  162.             Select Case k$
  163.                 Case "1": GoSub do1
  164.                 Case "2": GoSub do2
  165.                 Case "3": Mode = 3
  166.                 Case "4": GoSub do4
  167.                 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"
  168.                     Guesses$(HighLited) = k$ ' for screen updates
  169.                     For i = 1 To Len(Working$)
  170.                         If Letters$(HighLited) = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = k$
  171.                     Next
  172.                     Mode = 0
  173.             End Select
  174.         ElseIf Mode = 3 Then
  175.             Locate 25, 44: Print Space$(31); ' clear out old line
  176.             c$ = LCodes$(Asc(k$) - 64)
  177.             Guesses$(Asc(c$) - 64) = k$
  178.             For i = 1 To Len(Working$)
  179.                 If c$ = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = k$
  180.             Next
  181.             Mode = 0
  182.         End If
  183.     End If
  184.     _Limit 30
  185.     _Display
  186. Loop Until Working$ = UCase$(Answer$)
  187. Update
  188. Color Orange, Back
  189. cp 19, "You got it!    5 secs to next puzzle..."
  190. GoTo restart
  191.  
  192. do1: ' display answer
  193. Working$ = UCase$(Answer$) ' show the answer$ guesses correct moves to next puzzle
  194. Mode = 0
  195.  
  196. do2: ' get decode letter for highlighted Letter
  197. For i = 1 To 26
  198.     If LCodes$(i) = Letters$(HighLited) Then c$ = Chr$(i + 64): Exit For
  199. Guesses$(HighLited) = c$ ' for screen updates
  200. For i = 1 To Len(Working$)
  201.     If Letters$(HighLited) = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = c$
  202. Mode = 0
  203.  
  204. do4: ' clear guess letter from code letter
  205. Guesses$(HighLited) = "-"
  206. For i = 1 To Len(Working$)
  207.     If Letters$(HighLited) = Mid$(Coded$, i, 1) Then Mid$(Working$, i, 1) = "*" ' clear the letter
  208. Mode = 0
  209. Update
  210.  
  211. 'one liners
  212. Data "Why do ghosts go on diets? So they can keep their ghoulish figures"
  213. Data "Where does a ghost go on vacation? Mali-boo."
  214. Data "Why did the ghost go into the bar? For the Boos."
  215. Data "What is in a ghost's nose? Boo-gers."
  216. Data "Why did the policeman ticket the ghost on Halloween? It didn't have a haunting license."
  217. Data "Why do demons and ghouls hang out together? Because demons are a ghoul's best friend!"
  218. Data "Why did the ghost starch his sheet? He wanted everyone scared stiff."
  219. Data "What does a panda ghost eat? Bam-BOO!"
  220. Data "What's a ghost's favorite dessert? I-Scream!"
  221. Data "Where do ghosts buy their food? At the ghost-ery store!"
  222. Data "How do you know when a ghost is sad? He starts boo hooing."
  223. Data "Why don't mummies take time off? They're afraid to unwind."
  224. Data "Why did the headless horseman go into business? He wanted to get ahead in life."
  225. Data "What kind of music do mummies like listening to on Halloween? Wrap music."
  226. Data "Why don't mummies have friends? Because they're too wrapped up in themselves."
  227. Data "Why did the vampire read the newspaper? He heard it had great circulation."
  228. Data "How do vampires get around on Halloween? On blood vessels."
  229. Data "What's it like to be kissed by a vampire? It's a pain in the neck."
  230. Data "What's it called when a vampire has trouble with his house? A grave problem."
  231. Data "How can you tell when a vampire has been in a bakery? All the jelly has been sucked out of the jelly doughnuts."
  232. Data "What do you get when you cross a vampire and a snowman? Frostbite."
  233. Data "Why do skeletons have low self-esteem? They have no body to love."
  234. Data "Know why skeletons are so calm? Because nothing gets under their skin."
  235. Data "What do you call a cleaning skeleton? The grim sweeper."
  236. Data "What do skeletons order at a restaurant? Spare ribs."
  237. Data "What do you call a witch's garage? A broom closet."
  238. Data "What kind of food would you find on a haunted beach? A sand-witch!"
  239. Data "What was the witch's favorite subject in school? Spelling."
  240. Data "What do you call two witches who live together? Broom-mates!"
  241. Data "What's a witch's favorite makeup? Ma-scare-a."
  242. Data "Who helps the little pumpkins cross the road safely? The crossing gourd."
  243. Data "What treat do eye doctors give out on Halloween? Candy corneas."
  244. Data "What type of plants do well on all Hallow's Eve? Bam-BOO!"
  245. Data "What do birds say on Halloween? Trick or tweet!"
  246. Data "Why don't skeletons ever go trick or treating? Because they have no-body to go with."
  247. Data "Where do ghosts buy their Halloween candy? At the ghost-ery store!"
  248. Data "What do owls say when they go trick or treating? 'Happy Owl-ween!'"
  249. Data "What do ghosts give out to trick or treaters? Booberries!"
  250. Data "Who did Frankenstein go trick or treating with? His ghoul friend."
  251. Data "What Halloween candy is never on time for the party? Choco-LATE!"
  252. Data "What do witches put on to go trick or treating? Mas-scare-a."
  253. Data "What does Bigfoot say when he asks for candy?  'Trick-or-feet!'"
  254. Data "Which type of pants do ghosts wear to trick or treat? Boo jeans."
  255. Data "What makes trick or treating with twin witches so challenging? You never know which witch is which!"
  256. Data "What happens when a vampire goes in the snow? Frost bite!"
  257. Data "What do you call two witches living together? Broommates"
  258. Data "What position does a ghost play in hockey? Ghoulie."
  259. Data "What do mummies listen to on Halloween? Wrap music."
  260. Data "How do you make a skeleton laugh? You tickle his funny bone!"
  261. Data "Which Halloween monster is good at math? Count Dracula!"
  262. Data "Why did the Cyclops give up teaching? He only had one pupil!"
  263. Data "Why didn't the skeleton go to see a scary movie? He didn't have the guts."
  264. Data "What did the boy ghost say to the girl ghost? 'You sure are boo-tiful!'"
  265. Data "Where does Dracula keep his money? In a blood bank."
  266. Data "Why are ghosts terrible liars? You can see right through them!"
  267. Data "Why don't mummies take vacations? They're afraid to unwind."
  268. Data "What is a vampire's favorite holiday, besides Halloween? Fangs-giving!"
  269. Data "Where do fashionable ghosts shop? Bootiques!"
  270. Data "What's a monster's favorite play? Romeo and Ghouliet!"
  271. Data "What room does a ghost not need? A living room."
  272. Data "What monster plays tricks on Halloween? Prank-enstein!"
  273. Data "What's a ghost's favorite dessert? I scream."
  274. Data "What does the skeleton chef say when he serves you a meal? 'Bone Appetit!'"
  275. Data "What is a vampire's favorite fruit? A neck-tarine!"
  276. Data "What do witches put on their bagels? Scream cheese."
  277. Data "What do ghosts eat for dinner? Spook-ghetti!"
  278. Data "What do skeletons order at restaurants? Spare ribs."
  279. Data "What does a panda ghost eat? Bam-BOO!"
  280. Data "What tops off a mummy's ice cream sundae? Whipped scream."
  281. Data "What's a ghost's favorite yogurt flavor? Boo-berry!"
  282. Data "What's a vampire's least favorite meal? A steak!"
  283. Data "Why was the candy corn booed off the stage? All of his jokes were too corny!"
  284. Data "EOD"
  285.  
  286. Sub Update ' preserve from ravages of graphics effects ;-))
  287.     Dim As Integer i, spaces
  288.     Dim w$, c$, a$, h$, pc$
  289.     Color Yellow, Back
  290.     Locate 17, (120 - Len(Answer$)) / 2: Print Coded$;
  291.     Color White, Back
  292.     Locate 18, (120 - Len(Answer$)) / 2
  293.     For i = 1 To Len(Answer$)
  294.         w$ = Mid$(Working$, i, 1): c$ = Mid$(Coded$, i, 1)
  295.         a$ = Mid$(Answer$, i, 1): h$ = Letters$(HighLited)
  296.         If w$ = "*" Then
  297.             pc$ = "*": If h$ = c$ Then Color White, Blue Else Color White, Back
  298.         Else
  299.             Color White, Back: If w$ = UCase$(a$) Then pc$ = a$ Else pc$ = w$
  300.         End If
  301.         Print pc$;
  302.     Next
  303.     spaces = 9
  304.     For i = 1 To 26 'blue background highlighter
  305.         If i = HighLited Then Color Yellow, Blue Else Color Yellow, Back
  306.         Locate 21, spaces: Print Letters$(i);
  307.         If i = HighLited Then Color Yellow, Blue Else Color White, Back
  308.         Locate 22, spaces: Print Guesses$(i);
  309.         spaces = spaces + 4
  310.     Next
  311.     If Mode = 1 Then
  312.         Color White, Back
  313.         cp 24, "  Guess Solve Letter or Menu # "
  314.         cp 25, String$(31, "W") ' for worm poison (the fore color)
  315.     ElseIf Mode = 0 Then
  316.         Color Yellow, Back
  317.         cp 24, "  Select Code Letter or Menu # "
  318.         cp 25, String$(31, "W") ' for worm poison (the fore color)
  319.     ElseIf Mode = 3 Then
  320.         Color White, Back
  321.         cp 24, "     Select Letter to Find     "
  322.         cp 25, String$(31, "W") ' for worm poison (the fore color)
  323.     End If
  324.  
  325. Sub DisplayInstructions ' only once let worms eat them up as game goes on
  326.     Color Orange, Back: Cls
  327.     cp 4, "*** Halloween Challenge - Crypt-O-Gram Puzzle ***"
  328.     Color Red
  329.     cp 6, "Solve puzzle by selecting a Code letter then selecting a Guess letter for it."
  330.     cp 7, "All selections are made by pressing spacebar when you see your letter or digit."
  331.     cp 8, "You will need to verify your selection by pressing spacebar again when see Y for Yes."
  332.     cp 9, "Use the escape key to quit immediately (an X box in top right is not accessible)."
  333.     Color BB
  334.     cp 11, "To get the answer and move onto next puzzle, select 1."
  335.     cp 12, "To decode current highlighted letter, select 2."
  336.     cp 13, "To solve a letter, select 3 and then select letter to find."
  337.     cp 14, "To clear a guess at highlighted Code letter, select 4."
  338.  
  339. Sub cp (row, text$) ' center text on text screen
  340.     'Locate row, 1: Print Space$(_Width) ' clear out old line in case the next is shorter
  341.     'Locate row, 1: Print Space$(Xmax / 8);  'text screen
  342.     ' clear old line was interferring with worm trails
  343.     Locate row, (Xmax / 8 - Len(text$)) / 2: Print text$;
  344.  
  345. Function choice$ (row, col, selection$) ' replace InKey$ with _KeyDown()
  346.     Dim As _Unsigned Long fg, bg
  347.     Dim As Integer saveRow, saveCol, i
  348.     Dim k$
  349.     fg~& = _DefaultColor: bg~& = _BackgroundColor
  350.     saveRow = CsrLin: saveCol = Pos(0)
  351.     If _KeyDown(27) Then System ' emergency exit
  352.     GoSub show:
  353.     k$ = InKey$
  354.     If _KeyDown(27) Then System ' emergency exit
  355.     If k$ = " " Then KeyTimer = Timer: Place = (Place + 1) Mod Len(selection$)
  356.     If Timer - KeyTimer >= 4 Then choice$ = Mid$(selection$, Place + 1, 1): Place = 0
  357.     Locate saveRow, saveCol: Exit Function
  358.  
  359.     show:
  360.     Locate row, col
  361.     For i = 1 To Len(selection$)
  362.         If i = Place + 1 Then Color bg~&, fg~& Else Color fg~&, bg~&
  363.         Locate row, col - 1 + i: Print Mid$(selection$, i, 1);
  364.     Next
  365.     '_Display
  366.     Color fg~&, bg~&
  367.     Return
  368.  
  369. Sub DrawWorms (DrawReset As Integer) ' one frame in main loop
  370.     Static x(1 To nWorms, 1 To 20), y(1 To nWorms, 1 To 20)
  371.     Dim M As _MEM
  372.     Dim As Integer i, j, good
  373.     Dim As Single x, y, xx, yy
  374.     _Source 0
  375.     If DrawReset Then
  376.         'M = _Mem(x())
  377.         '_MemFill M, M.OFFSET, M.SIZE, 0 As _BYTE 'reset the array, Thanks Steve
  378.         'M = _Mem(y())
  379.         '_MemFill M, M.OFFSET, M.SIZE, 0 As _BYTE 'reset the array, eh didn't work
  380.         For i = 1 To nWorms
  381.             NewWorm i
  382.             For j = 1 To 20
  383.                 x(i, j) = 0: y(i, j) = 0
  384.             Next
  385.         Next
  386.         DrawReset = 0
  387.     End If
  388.     For i = 1 To nWorms
  389.         _Dest WT
  390.         Fcirc Worms(i).X, Worms(i).Y, 6, &HFF000000
  391.         _Dest 0
  392.         If _KeyDown(27) Then Exit Sub
  393.         For j = 1 To Worms(i).Sz ' blackout old segments
  394.             If x(i, j) And y(i, j) Then Fcirc x(i, j), y(i, j), 8, &HFF000000
  395.         Next
  396.  
  397.         If Rnd < .15 Then 'move the worm  (gots to slow down the worms)
  398.             tryAgain:
  399.             If _KeyDown(27) Then Exit Sub
  400.             If Rnd < .3 Then Worms(i).DX = Worms(i).DX + .8 * Rnd - .4 Else Worms(i).DY = Worms(i).DY + .8 * Rnd - .4
  401.             If Worms(i).DX ^ 2 + Worms(i).DY ^ 2 > 2 Then
  402.                 Worms(i).DX = Worms(i).DX * .5: Worms(i).DY = Worms(i).DY * .5
  403.             End If
  404.             x = Worms(i).X + Worms(i).DX * 2.0: y = Worms(i).Y + Worms(i).DY * 2.0
  405.             good = -1
  406.             If x >= WormYard.X + 6 And x <= WormYard.X + WormYard.W - 6 Then
  407.                 If y >= WormYard.Y + 6 And y <= WormYard.Y + WormYard.H - 6 Then
  408.                     For yy = y - 6 To y + 6
  409.                         For xx = x - 6 To x + 6
  410.                             If Point(xx, yy) = White Or Point(xx, yy) = Yellow Then good = 0: Exit For
  411.                         Next
  412.                         If good = 0 Then Exit For
  413.                     Next
  414.                 Else
  415.                     good = 0
  416.                 End If
  417.             Else
  418.                 good = 0
  419.             End If
  420.             If good = 0 Then 'turn the worm
  421.                 If Rnd > .5 Then 'change dx
  422.                     If Worms(i).DX Then
  423.                         Worms(i).DX = -Worms(i).DX
  424.                     Else
  425.                         If Rnd > .5 Then Worms(i).DX = 1 Else Worms(i).DX = -1
  426.                     End If
  427.                 Else
  428.                     If Worms(i).DY Then
  429.                         Worms(i).DY = -Worms(i).DY
  430.                     Else
  431.                         If Rnd > .5 Then Worms(i).DY = 1 Else Worms(i).DY = -1
  432.                     End If
  433.                 End If
  434.                 GoTo tryAgain
  435.             End If
  436.  
  437.             For j = Worms(i).Sz To 2 Step -1
  438.                 x(i, j) = x(i, j - 1): y(i, j) = y(i, j - 1)
  439.                 If x(i, j) And y(i, j) Then DrawBall x(i, j), y(i, j), 6, Worms(i).C1
  440.             Next
  441.             x(i, 1) = x: y(i, 1) = y
  442.             DrawBall x(i, 1), y(i, 1), 6, Worms(i).C1
  443.             Worms(i).X = x: Worms(i).Y = y
  444.         Else
  445.             For j = Worms(i).Sz To 2 Step -1
  446.                 If x(i, j) And y(i, j) Then DrawBall x(i, j), y(i, j), 6, Worms(i).C1
  447.             Next
  448.             DrawBall x(i, 1), y(i, 1), 6, Worms(i).C1
  449.         End If
  450.     Next i 'worm index
  451.  
  452. Sub NewWormYard (x, y, w, h)
  453.     WormYard.X = x: WormYard.Y = y: WormYard.W = w: WormYard.H = h
  454.  
  455. Sub NewWorm (i)
  456.     Dim As Integer side, lev
  457.     'pick which side to enter, for dx, dy generally headed towards inner screen
  458.     side = Int(Rnd * 4)
  459.     Select Case side
  460.         Case 0 ' left side
  461.             Worms(i).X = WormYard.X + 6
  462.             Worms(i).Y = WormYard.Y + 6 + (WormYard.H - 12) * Rnd
  463.             Worms(i).DX = 1
  464.             Worms(i).DY = 0
  465.         Case 1 'right side
  466.             Worms(i).X = WormYard.X + WormYard.W - 6
  467.             Worms(i).Y = WormYard.Y + 6 + (WormYard.H - 12) * Rnd
  468.             Worms(i).DX = -1
  469.             Worms(i).DY = 0
  470.         Case 2 ' top
  471.             Worms(i).Y = WormYard.Y + 6
  472.             Worms(i).X = WormYard.X + 6 + (WormYard.W - 12) * Rnd
  473.             Worms(i).DX = 0
  474.             Worms(i).DY = 1
  475.         Case 3 'bottom
  476.             Worms(i).Y = WormYard.Y + WormYard.H - 6
  477.             Worms(i).X = WormYard.X + 6 + (WormYard.W - 12) * Rnd
  478.             Worms(i).DX = 0
  479.             Worms(i).DY = -1
  480.     End Select
  481.     Worms(i).Sz = Int(Rnd * 11) + 10
  482.     side = Int(Rnd * 4): lev = Int(Rnd * 10)
  483.     If side = 0 Then
  484.         Worms(i).C1 = _RGB32(255 - 20 * lev + 50, 180 - 15 * lev, 180 - 15 * lev)
  485.     ElseIf side = 1 Then
  486.         Worms(i).C1 = _RGB32(255 - 20 * lev, 180 - 15 * lev + 50, 180 - 15 * lev)
  487.     ElseIf side = 2 Then
  488.         Worms(i).C1 = _RGB32(255 - 20 * lev, 180 - 15 * lev, 180 - 15 * lev + 20)
  489.     ElseIf side = 3 Then
  490.         Worms(i).C1 = _RGB32(255 - 20 * lev, 180 - 15 * lev, 180 - 15 * lev)
  491.     End If
  492.  
  493. Sub newSpinner (i As Integer) 'set Spinners dimensions start angles, color?
  494.     Dim r As Integer
  495.     S(i).Sz = Rnd * .2 + .4
  496.     If Rnd < .5 Then r = -1 Else r = 1
  497.     S(i).DX = (S(i).Sz * Rnd * 2 + 2) * r * 1.25: S(i).DY = (S(i).Sz * Rnd * 2 + 2) * r * 1.25
  498.     r = Int(Rnd * 4)
  499.     Select Case r
  500.         Case 0: S(i).X = Rnd * (Xmax - 120) + 60: S(i).Y = 0: If S(i).DY < 0 Then S(i).DY = -S(i).DY
  501.         Case 1: S(i).X = Rnd * (Xmax - 120) + 60: S(i).Y = Ymax: If S(i).DY > 0 Then S(i).DY = -S(i).DY
  502.         Case 2: S(i).X = 0: S(i).Y = Rnd * (Ymax - 120) + 60: If S(i).DX < 0 Then S(i).DX = -S(i).DX
  503.         Case 3: S(i).X = Xmax: S(i).Y = Rnd * (Ymax - 120) + 60: If S(i).DX > 0 Then S(i).DX = -S(i).DX
  504.     End Select
  505.     r = Rnd * 90 + 30
  506.     S(i).C1 = _RGB32(r, Rnd * .5 * r, Rnd * .25 * r) 'red ghost spiders???
  507.  
  508. Sub drawSpinner (x As Integer, y As Integer, scale As Single, heading As Single, c As _Unsigned Long)
  509.     Dim x1, x2, x3, x4, y1, y2, y3, y4, r, a, a1, a2, lg, d, rd
  510.     Dim rred, bblue, ggreen
  511.     Static switch As Integer
  512.     switch = switch + 2
  513.     switch = switch Mod 16 + 1
  514.     rred = _Red32(c): ggreen = _Green32(c): bblue = _Blue32(c)
  515.     r = 10 * scale
  516.     x1 = x + r * Cos(heading): y1 = y + r * Sin(heading)
  517.     r = 2 * r 'lg lengths
  518.     For lg = 1 To 8
  519.         If lg < 5 Then
  520.             a = heading + .9 * lg * _Pi(1 / 5) + (lg = switch) * _Pi(1 / 10)
  521.         Else
  522.             a = heading - .9 * (lg - 4) * _Pi(1 / 5) - (lg = switch) * _Pi(1 / 10)
  523.         End If
  524.         x2 = x1 + r * Cos(a): y2 = y1 + r * Sin(a)
  525.         drawLink x1, y1, 3 * scale, x2, y2, 2 * scale, _RGB32(rred + 20, ggreen + 10, bblue + 5)
  526.         If lg = 1 Or lg = 2 Or lg = 7 Or lg = 8 Then d = -1 Else d = 1
  527.         a1 = a + d * _Pi(1 / 12)
  528.         x3 = x2 + r * 1.5 * Cos(a1): y3 = y2 + r * 1.5 * Sin(a1)
  529.         drawLink x2, y2, 2 * scale, x3, y3, scale, _RGB32(rred + 35, ggreen + 17, bblue + 8)
  530.         rd = Int(Rnd * 8) + 1
  531.         a2 = a1 + d * _Pi(1 / 8) * rd / 8
  532.         x4 = x3 + r * 1.5 * Cos(a2): y4 = y3 + r * 1.5 * Sin(a2)
  533.         drawLink x3, y3, scale, x4, y4, scale, _RGB32(rred + 50, ggreen + 25, bblue + 12)
  534.     Next
  535.     r = r * .5
  536.     Fcirc x1, y1, r, _RGB32(rred - 20, ggreen - 10, bblue - 5)
  537.     x2 = x1 + (r + 1) * Cos(heading - _Pi(1 / 12)): y2 = y1 + (r + 1) * Sin(heading - _Pi(1 / 12))
  538.     Fcirc x2, y2, r * .2, &HFF000000
  539.     x2 = x1 + (r + 1) * Cos(heading + _Pi(1 / 12)): y2 = y1 + (r + 1) * Sin(heading + _Pi(1 / 12))
  540.     Fcirc x2, y2, r * .2, &HFF000000
  541.     r = r * 2
  542.     x1 = x + r * .9 * Cos(heading + _Pi): y1 = y + r * .9 * Sin(heading + _Pi)
  543.     TiltedEllipseFill 0, x1, y1, r, .7 * r, heading + _Pi, _RGB32(rred, ggreen, bblue)
  544.  
  545. Sub drawLink (x1, y1, r1, x2, y2, r2, c As _Unsigned Long)
  546.     Dim a, a1, a2, x3, x4, x5, x6, y3, y4, y5, y6
  547.     a = _Atan2(y2 - y1, x2 - x1)
  548.     a1 = a + _Pi(1 / 2)
  549.     a2 = a - _Pi(1 / 2)
  550.     x3 = x1 + r1 * Cos(a1): y3 = y1 + r1 * Sin(a1)
  551.     x4 = x1 + r1 * Cos(a2): y4 = y1 + r1 * Sin(a2)
  552.     x5 = x2 + r2 * Cos(a1): y5 = y2 + r2 * Sin(a1)
  553.     x6 = x2 + r2 * Cos(a2): y6 = y2 + r2 * Sin(a2)
  554.     fquad x3, y3, x4, y4, x5, y5, x6, y6, c
  555.     Fcirc x1, y1, r1, c
  556.     Fcirc x2, y2, r2, c
  557.  
  558. 'need 4 non linear points (not all on 1 line) list them clockwise so x2, y2 is opposite of x4, y4
  559. 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)
  560.     ftri x1, y1, x2, y2, x4, y4, c
  561.     ftri x3, y3, x4, y4, x1, y1, c
  562.  
  563. Sub ftri (x1, y1, x2, y2, x3, y3, K As _Unsigned Long)
  564.     Dim a&
  565.     a& = _NewImage(1, 1, 32)
  566.     _Dest a&
  567.     PSet (0, 0), K
  568.     _Dest 0
  569.     _MapTriangle _Seamless(0, 0)-(0, 0)-(0, 0), a& To(x1, y1)-(x2, y2)-(x3, y3)
  570.     _FreeImage a& '<<< this is important!
  571.  
  572. Sub TiltedEllipseFill (destHandle&, x0, y0, a, b, ang, c As _Unsigned Long)
  573.     Dim max As Integer, mx2 As Integer, i As Integer, j As Integer, k As Single, lasti As Single, lastj As Single
  574.     Dim prc As _Unsigned Long, tef As Long
  575.     prc = _RGB32(255, 255, 255, 255)
  576.     If a > b Then max = a + 1 Else max = b + 1
  577.     mx2 = max + max
  578.     tef = _NewImage(mx2, mx2)
  579.     _Dest tef
  580.     _Source tef 'point wont read without this!
  581.     For k = 0 To 6.2832 + .05 Step .1
  582.         i = max + a * Cos(k) * Cos(ang) + b * Sin(k) * Sin(ang)
  583.         j = max + a * Cos(k) * Sin(ang) - b * Sin(k) * Cos(ang)
  584.         If k <> 0 Then
  585.             Line (lasti, lastj)-(i, j), prc
  586.         Else
  587.             PSet (i, j), prc
  588.         End If
  589.         lasti = i: lastj = j
  590.     Next
  591.     Dim xleft(mx2) As Integer, xright(mx2) As Integer, x As Integer, y As Integer
  592.     For y = 0 To mx2
  593.         x = 0
  594.         While Point(x, y) <> prc And x < mx2
  595.             x = x + 1
  596.         Wend
  597.         xleft(y) = x
  598.         While Point(x, y) = prc And x < mx2
  599.             x = x + 1
  600.         Wend
  601.         While Point(x, y) <> prc And x < mx2
  602.             x = x + 1
  603.         Wend
  604.         If x = mx2 Then xright(y) = xleft(y) Else xright(y) = x
  605.     Next
  606.     _Dest destHandle&
  607.     For y = 0 To mx2
  608.         If xleft(y) <> mx2 Then Line (xleft(y) + x0 - max, y + y0 - max)-(xright(y) + x0 - max, y + y0 - max), c, BF
  609.     Next
  610.     _FreeImage tef
  611.  
  612. Sub Fcirc (CX As Long, CY As Long, R As Long, C As _Unsigned Long)
  613.     Dim Radius As Long, RadiusError As Long
  614.     Dim X As Long, Y As Long
  615.     Radius = Abs(R): RadiusError = -Radius: X = Radius: Y = 0
  616.     If Radius = 0 Then PSet (CX, CY), C: Exit Sub
  617.     Line (CX - X, CY)-(CX + X, CY), C, BF
  618.     While X > Y
  619.         RadiusError = RadiusError + Y * 2 + 1
  620.         If RadiusError >= 0 Then
  621.             If X <> Y + 1 Then
  622.                 Line (CX - Y, CY - X)-(CX + Y, CY - X), C, BF
  623.                 Line (CX - Y, CY + X)-(CX + Y, CY + X), C, BF
  624.             End If
  625.             X = X - 1
  626.             RadiusError = RadiusError - X * 2
  627.         End If
  628.         Y = Y + 1
  629.         Line (CX - X, CY - Y)-(CX + X, CY - Y), C, BF
  630.         Line (CX - X, CY + Y)-(CX + X, CY + Y), C, BF
  631.     Wend
  632.  
  633. Sub DrawBall (x, y, r, c As _Unsigned Long)
  634.     Dim rred As Long, grn As Long, blu As Long, rr As Long, f
  635.     rred = _Red32(c): grn = _Green32(c): blu = _Blue32(c)
  636.     For rr = r To 0 Step -1
  637.         f = 1.25 - rr / r
  638.         Fcirc x, y, rr, _RGB32(rred * f, grn * f, blu * f)
  639.     Next
  640.  

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #17 on: October 09, 2021, 12:59:28 am »
Break suggested? Advice taken. Let me know if you need anything else?
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 #18 on: October 09, 2021, 08:20:26 am »
Break suggested? Advice taken. Let me know if you need anything else?

Creepy Crypt Sound effects? (I like Pete's thunderstorm stuff, TheBob's pumpkin is great too but I have my own pumpkin I want to use.)

Oh hey, I need a ghost writer to get better jokes than what's in the Data section ;-))

Oh wait... we could do those (jokes other than ones in puzzle) in sound (oh maybe those jokes too that would be a nice trick or treat read the answer amongst the many told verbally while user is trying to concentrate on puzzle).
 
@johnno56 I prefer your sound files that are cross platform than using Windows only speech synthesis.

Maybe jokes not needed, just some haunting torment for the user while he attempts to decode a dead joke, moo ha ha. Make the user think he's died and gone to bad joke hell, AKA Pete's heaven.

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #19 on: October 09, 2021, 09:02:19 am »
Regardless of whether the synthesis is Windows-based or not, how can the 'results' be classified as 'non cross platform'? I can output the audio format to many types. I use 'ogg' because the compression is higher than 'wav' and 'mp3'...  I am confused... (not even a chuckle... lol)
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 #20 on: October 09, 2021, 09:05:24 am »
Windows speech synthesis, I think, can only be used in... wait for it.

Windows!

I mean it seems logical to me.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #21 on: October 09, 2021, 09:07:43 am »
@johnno56 if you give me sound stuff that works for you, and I test it and it works for me too, then I know 2 OS's at least that they will work. 2 is good enough for me to say cross platform.

Marked as best answer by bplus on October 11, 2021, 08:20:55 am

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #22 on: October 10, 2021, 02:37:47 am »
Well I try again, here is version 2021-10-10 of Crypto-O-Gram with 3 background sound and graphics effects. Had a last minute change of music files because the one I had was too big for forum post.
* Crypt-O-Gram Puzzle v2021-10-10.zip (Filesize: 8 MB, Downloads: 124)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #23 on: October 11, 2021, 11:41:41 am »
Ha! my bad timing to post above with all this new stuff with QB64 happening ;(

Then mpgcan stuff, wow!

Well I thought pretty good graphics and sound added, b+ at least, Moo ha ha.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #24 on: October 11, 2021, 12:18:10 pm »
Some screen shots from what may be my last Graphics version for Halloween Challenge (I think I have some ideas for Screen 0 extra credit version).

GE 1 effect great music on this one.PNG
* GE 1 effect great music on this one.PNG (Filesize: 81.25 KB, Dimensions: 1339x718, Views: 95)
GE 2 effect.PNG
* GE 2 effect.PNG (Filesize: 184.33 KB, Dimensions: 1346x761, Views: 97)
GE 3 FadeIn out.PNG
* GE 3 FadeIn out.PNG (Filesize: 255.5 KB, Dimensions: 1326x752, Views: 93)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Crypt-O-Gram Puzzle - Halloween Challenge
« Reply #25 on: October 11, 2021, 12:37:47 pm »
PS everything in this Crypt-0-gram Puzzle program is working fine in QB64 v2.0.

I did have to update all my Handy Functions that used the Function Name to build$ the string I was going to return with the Function call ;-(  actually wasn't hard to fix. Ironically the first program I tested QB64 v2.0 was Text Fetch and that was hard to figure out what was going on because the program was complex and I of course didn't remember what variable did what! Had me stumped for awhile but after figuring that I needed a build$ variable instead of Function name, all went sooth! This was before I watched Fellippe's video on $Debug but I don't think that would have helped with Function$ fixes.