_Title "Halloween Challenge: Crypt-O-Gram Puzzle" ' b+ started One Key Challenge 2021-09-25 ' from One Key Challenge - Cryptogram Puzzle 2021-10-02
' 2021-09-07 Jokes are intended for QB64 home programming entertainment use only.
' Thank you CountryLiving 1-33
' https://www.countryliving.com/entertaining/a32963261/halloween-jokes/
' Thank you GoodHousekeeping 34-72
' https://www.goodhousekeeping.com/holidays/halloween-ideas/a32998753/halloween-jokes/
' 2021-10-03 install new set of jokes and new Binary Select Input Algorithm
' Redo Mode system to fix differences of input methods.
' Recolor green background has me seeing Red!
' 2021-10-04 Steve McNeill came up with an easier to understand and use input system.
' Installing new Function and updating Game. Steve also told me how to change color palette,
' now we have some real Orange! for #12 meant for high red.
' Next version: Follow Steve's advice to use _KeyDown in stead of InKey$
' Improved Choice to reduce no response to keypress or double jumping.
' v 2021-10-07 install DrawWorms subroutines and get working.
'Fall letters and background
Const Orange
= &HFFFF8800 ' 12 d Const White
= &HFFFFFFFF ' 15 d Const Back
= &HFF302010 ' 8 ? d Const Red
= &HFFFF2222 ' print under title Const Yellow
= &HFFFFFF00 ' 14 d Const Blue
= &HFF0000FF ' 9 light blue Const BB
= &HFF33BB33 ' 6 blue brown ? Const Xmax
= 120 * 8 ' started with text screen _width 120, 30
'for Graphic effects
'for graphics effects
X
As Single ' usu top left corner could be center depending on object DIR
As Single ' short for direction or heading usu a radian angle Act
As Integer ' lives countdown or just plain ACTive TF
Dim Shared Answer$
' beginning phrase to be guessed ' 3 stages of the Puzzle Dim Shared Working$
' decoded and solved when working$ becomes = ucase$(answer$) Dim Shared Letters$
(1 To 26) ' for coding and highlited letters Dim Shared LCodes$
(1 To 26) ' for code and decode by number 1 to 26 Dim Shared Guesses$
(1 To 26) ' track all the guess to decode Dim Shared HighLited
' cursor over letters to guess
' adding graphics effects
_FullScreen 'I guess it does make it easier to tell E from F...
Dim jokes$
(1 To 100) ' load jokes one time from data statements in program
restart:
'setup Puzzle and code it
Answer$
= jokes$
(Int(Rnd * jCount
) + 1)For i
= 1 To 26: Guesses$
(i
) = "-":
Next 'setup the display guesses array For i
= 1 To 26 ' use letters for display of letters to pick second and to create a code Letters$
(i
) = Chr$(i
+ 64) LCodes$(i) = Letters$(i) ' these will convert between each other by index number
For i
= 26 To 2 Step -1 ' shuffle the letters in LCode$() Coded$ = "": Working$ = "" ' reset for next go around
For i
= 1 To Len(Answer$
) 'third: put the phrase in coded$ and hide it in working$ Coded$ = Coded$ + LCodes$(a - 64)
Working$ = Working$ + "*"
Coded$
= Coded$
+ Mid$(Answer$
, i
, 1) Working$
= Working$
+ Mid$(Answer$
, i
, 1)
HighLited = 1 'setup done start game
Mode = 0
'select a grahics effect on timer
GE = 1 ' <<< convert to pick at random from N effects
resetWorms% = -1
DrawWorms resetWorms% ' get draw worms started on a new set o worms
resetWorms% = 0 ' dont reset while running on timer
On Timer(0.5) DrawWorms resetWorms%
DisplayInstructions '<< this part can be eaten by worms
Update ' this part is critical to continue work on puzzle
DrawWorms resetWorms
k$ = choice$(25, 44, " 1234ABCDEFGHIJKLMNOPQRSTUVWXYZ")
If Mode
= 0 Then ' highlight a letter 'm replaces arrows and mouse select of highlited 1 to 26 for letters
test
= InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", k$
) HighLited = test
Mode = 1
Mode = 0
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" Guesses$(HighLited) = k$ ' for screen updates
If Letters$
(HighLited
) = Mid$(Coded$
, i
, 1) Then Mid$(Working$
, i
, 1) = k$
Mode = 0
Update
Update
cp 19, "You got it! 5 secs to next puzzle..."
do1: ' display answer
Working$
= UCase$(Answer$
) ' show the answer$ guesses correct moves to next puzzleMode = 0
Update
do2: ' get decode letter for highlighted Letter
Guesses$(HighLited) = c$ ' for screen updates
If Letters$
(HighLited
) = Mid$(Coded$
, i
, 1) Then Mid$(Working$
, i
, 1) = c$
Update
Mode = 0
do3: ' find a uncoded letter
cp 24, " Select Letter to Find "
d$ = choice$(25, 46, " ABCDEFGHIJKLMNOPQRSTUVWXYZ")
c$
= LCodes$
(Asc(d$
) - 64) Guesses$
(Asc(c$
) - 64) = d$
Mode = 0
Update
do4: ' clear guess letter from code letter
Guesses$(HighLited) = "-"
If Letters$
(HighLited
) = Mid$(Coded$
, i
, 1) Then Mid$(Working$
, i
, 1) = "*" ' clear the letter Mode = 0
Update
'one liners
Data "Why do ghosts go on diets? So they can keep their ghoulish figures" Data "Where does a ghost go on vacation? Mali-boo." Data "Why did the ghost go into the bar? For the Boos." Data "What is in a ghost's nose? Boo-gers." Data "Why did the policeman ticket the ghost on Halloween? It didn't have a haunting license." Data "Why do demons and ghouls hang out together? Because demons are a ghoul's best friend!" Data "Why did the ghost starch his sheet? He wanted everyone scared stiff." Data "What does a panda ghost eat? Bam-BOO!" Data "What's a ghost's favorite dessert? I-Scream!" Data "Where do ghosts buy their food? At the ghost-ery store!" Data "How do you know when a ghost is sad? He starts boo hooing." Data "Why don't mummies take time off? They're afraid to unwind." Data "Why did the headless horseman go into business? He wanted to get ahead in life." Data "What kind of music do mummies like listening to on Halloween? Wrap music." Data "Why don't mummies have friends? Because they're too wrapped up in themselves." Data "Why did the vampire read the newspaper? He heard it had great circulation." Data "How do vampires get around on Halloween? On blood vessels." Data "What's it like to be kissed by a vampire? It's a pain in the neck." Data "What's it called when a vampire has trouble with his house? A grave problem." Data "How can you tell when a vampire has been in a bakery? All the jelly has been sucked out of the jelly doughnuts." Data "What do you get when you cross a vampire and a snowman? Frostbite." Data "Why do skeletons have low self-esteem? They have no body to love." Data "Know why skeletons are so calm? Because nothing gets under their skin." Data "What do you call a cleaning skeleton? The grim sweeper." Data "What do skeletons order at a restaurant? Spare ribs." Data "What do you call a witch's garage? A broom closet." Data "What kind of food would you find on a haunted beach? A sand-witch!" Data "What was the witch's favorite subject in school? Spelling." Data "What do you call two witches who live together? Broom-mates!" Data "What's a witch's favorite makeup? Ma-scare-a." Data "Who helps the little pumpkins cross the road safely? The crossing gourd." Data "What treat do eye doctors give out on Halloween? Candy corneas." Data "What type of plants do well on all Hallow's Eve? Bam-BOO!" Data "What do birds say on Halloween? Trick or tweet!" Data "Why don't skeletons ever go trick or treating? Because they have no-body to go with." Data "Where do ghosts buy their Halloween candy? At the ghost-ery store!" Data "What do owls say when they go trick or treating? 'Happy Owl-ween!'" Data "What do ghosts give out to trick or treaters? Booberries!" Data "Who did Frankenstein go trick or treating with? His ghoul friend." Data "What Halloween candy is never on time for the party? Choco-LATE!" Data "What do witches put on to go trick or treating? Mas-scare-a." Data "What does Bigfoot say when he asks for candy? 'Trick-or-feet!'" Data "Which type of pants do ghosts wear to trick or treat? Boo jeans." Data "What makes trick or treating with twin witches so challenging? You never know which witch is which!" Data "What happens when a vampire goes in the snow? Frost bite!" Data "What do you call two witches living together? Broommates" Data "What position does a ghost play in hockey? Ghoulie." Data "What do mummies listen to on Halloween? Wrap music." Data "How do you make a skeleton laugh? You tickle his funny bone!" Data "Which Halloween monster is good at math? Count Dracula!" Data "Why did the Cyclops give up teaching? He only had one pupil!" Data "Why didn't the skeleton go to see a scary movie? He didn't have the guts." Data "What did the boy ghost say to the girl ghost? 'You sure are boo-tiful!'" Data "Where does Dracula keep his money? In a blood bank." Data "Why are ghosts terrible liars? You can see right through them!" Data "Why don't mummies take vacations? They're afraid to unwind." Data "What is a vampire's favorite holiday, besides Halloween? Fangs-giving!" Data "Where do fashionable ghosts shop? Bootiques!" Data "What's a monster's favorite play? Romeo and Ghouliet!" Data "What room does a ghost not need? A living room." Data "What monster plays tricks on Halloween? Prank-enstein!" Data "What's a ghost's favorite dessert? I scream." Data "What does the skeleton chef say when he serves you a meal? 'Bone Appetit!'" Data "What is a vampire's favorite fruit? A neck-tarine!" Data "What do witches put on their bagels? Scream cheese." Data "What do ghosts eat for dinner? Spook-ghetti!" Data "What do skeletons order at restaurants? Spare ribs." Data "What does a panda ghost eat? Bam-BOO!" Data "What tops off a mummy's ice cream sundae? Whipped scream." Data "What's a ghost's favorite yogurt flavor? Boo-berry!" Data "What's a vampire's least favorite meal? A steak!" Data "Why was the candy corn booed off the stage? All of his jokes were too corny!"
Sub Update
' preserve from ravages of graphics effects ;-)) w$
= Mid$(Working$
, i
, 1): c$
= Mid$(Coded$
, i
, 1) a$
= Mid$(Answer$
, i
, 1): h$
= Letters$
(HighLited
) spaces = 9
For i
= 1 To 26 'blue background highlighter spaces = spaces + 4
cp 24, " Guess Solve Letter or Menu # "
cp 24, " Select Code Letter or Menu # "
Sub DisplayInstructions
' only once let worms eat them up as game goes on cp 4, "*** Halloween Challenge - Crypt-O-Gram Puzzle ***"
cp 6, "Solve puzzle by selecting a Code letter then selecting a Guess letter for it."
cp 7, "All selections are made by pressing spacebar when you see your letter or digit."
cp 8, "You will need to verify your selection by pressing spacebar again when see Y for Yes."
cp 9, "Use the escape key to quit immediately (an X box in top right is not accessible)."
cp 11, "To get the answer and move onto next puzzle, select 1."
cp 12, "To decode current highlighted letter, select 2."
cp 13, "To solve a letter, select 3 and then select letter to find."
cp 14, "To clear a guess at highlighted Code letter, select 4."
Sub cp
(row
, text$
) ' center text on text screen 'Locate row, 1: Print Space$(_Width) ' clear out old line in case the next is shorter
'Locate row, 1: Print Space$(Xmax / 8); 'text screen
' clear old line was interferring with worm trails
Function choice$
(row
, col
, selection$
) ' replace InKey$ with _KeyDown() ' 2021-10-06 fix for polling erratic behavior: misses or jumps, check for spacebar way more often
While Timer - t
< 4 ' smooth out the jumpiness sometimes no response, sometimes jumps 2x' on one press???? _Limit 200 '<<<< fine tune the polling for spacebar!!! _Limit 5 'so can hold down spacebar, nice show:
Sub DrawWorms
(DrawReset
As Integer) ' one frame in main loop NewWorm i
x(i, j) = 0: y(i, j) = 0
DrawReset = 0
Fcirc Worms(i).X, Worms(i).Y, 8, &HFF000000 ' fix 2021-10-07 to prevent program hangs
For j
= 1 To Worms
(i
).Sz
' blackout old segments If x
(i
, j
) And y
(i
, j
) Then Fcirc x
(i
, j
), y
(i
, j
), 8, &HFF000000 tryAgain:
If Rnd < .3 Then Worms
(i
).DX
= Worms
(i
).DX
+ .8 * Rnd - .4 Else Worms
(i
).DY
= Worms
(i
).DY
+ .8 * Rnd - .4 If Abs(Worms
(i
).DX
) > 2 Then Worms
(i
).DX
= Worms
(i
).DX
* .5 If Abs(Worms
(i
).DY
) > 2 Then Worms
(i
).DY
= Worms
(i
).DY
* .5 x = Worms(i).X + Worms(i).DX * 2.0: y = Worms(i).Y + Worms(i).DY * 2.0
good = -1
If x
>= WormYard.X
+ 6 And x
<= WormYard.X
+ WormYard.W
- 6 Then If y
>= WormYard.Y
+ 6 And y
<= WormYard.Y
+ WormYard.H
- 6 Then good = 0
good = 0
If good
= 0 Then 'turn the worm 'Beep: Locate 1, 1: Print x, y
'Input "enter >", w$
Worms(i).DX = -Worms(i).DX
Worms(i).DY = -Worms(i).DY
x(i, j) = x(i, j - 1): y(i, j) = y(i, j - 1)
If x
(i
, j
) And y
(i
, j
) Then DrawBall x
(i
, j
), y
(i
, j
), 6, Worms
(i
).C1
x(i, 1) = x: y(i, 1) = y
DrawBall x(i, 1), y(i, 1), 6, Worms(i).C1
Worms(i).X = x: Worms(i).Y = y
Sub NewWormYard
(x
, y
, w
, h
) WormYard.X = x: WormYard.Y = y: WormYard.W = w: WormYard.H = h
NewWorm i
'pick which side to enter, for dx, dy generally headed towards inner screen
Worms(i).X = WormYard.X + 6
Worms
(i
).Y
= WormYard.Y
+ 6 + (WormYard.H
- 12) * Rnd Worms(i).DX = 1
Worms(i).DY = 0
Worms(i).X = WormYard.X + WormYard.W - 6
Worms
(i
).Y
= WormYard.Y
+ 6 + (WormYard.H
- 12) * Rnd Worms(i).DX = -1
Worms(i).DY = 0
Worms(i).Y = WormYard.Y + 6
Worms
(i
).X
= WormYard.X
+ 6 + (WormYard.W
- 12) * Rnd Worms(i).DX = 0
Worms(i).DY = 1
Worms(i).Y = WormYard.Y + WormYard.H - 6
Worms
(i
).X
= WormYard.X
+ 6 + (WormYard.W
- 12) * Rnd Worms(i).DX = 0
Worms(i).DY = -1
Worms
(i
).Sz
= Int(Rnd * 11) + 10 Worms
(i
).C1
= _RGB32(255 - 20 * lev
+ 50, 180 - 15 * lev
, 180 - 15 * lev
) Worms
(i
).C1
= _RGB32(255 - 20 * lev
, 180 - 15 * lev
+ 50, 180 - 15 * lev
) Worms
(i
).C1
= _RGB32(255 - 20 * lev
, 180 - 15 * lev
, 180 - 15 * lev
+ 20) Worms
(i
).C1
= _RGB32(255 - 20 * lev
, 180 - 15 * lev
, 180 - 15 * lev
)
Radius
= Abs(R
): RadiusError
= -Radius: X
= Radius: Y
= 0 Line (CX
- X
, CY
)-(CX
+ X
, CY
), C
, BF
RadiusError = RadiusError + Y * 2 + 1
Line (CX
- Y
, CY
- X
)-(CX
+ Y
, CY
- X
), C
, BF
Line (CX
- Y
, CY
+ X
)-(CX
+ Y
, CY
+ X
), C
, BF
X = X - 1
RadiusError = RadiusError - X * 2
Y = Y + 1
Line (CX
- X
, CY
- Y
)-(CX
+ X
, CY
- Y
), C
, BF
Line (CX
- X
, CY
+ Y
)-(CX
+ X
, CY
+ Y
), C
, BF
f = 1.25 - rr / r
Fcirc x
, y
, rr
, _RGB32(rred
* f
, grn
* f
, blu
* f
)