_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.
' v 2021-10-08: fix do3, blanking whole line or nearly, it disturbs worm trails.
' Add a spider screen for overlaying spiders wo changing the background.
' Man this is so screwed up... I'm taking another approach.
' ... rewrites and tests
' Now do3 completely rewritten as mode 3 along with Choice$ function
' Much better!! rewrote the way Choice works, no time consuming loops outside main loop,
' so no delaysin graphics effects so no need for timers. Only one side screen needed
' for tracking Worm Trails. Had to slow worms and Spider dowm for a _Limit 30 for everything.
'Fall letters and background
Const Orange
= &HFFFF8800 ' 12 d Const Back
= &HFF302010 ' 8 ? d Const Red
= &HFFFF2222 ' print under title 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 TFWhite
= _RGB32(255, 255, 255): Yellow
= _RGB32(255, 255, 0) ' I give up, yellow and white aren't stopping the wormsDim 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 Dim Shared Mode
' what are we getting a coded letter =0, a guess for that letter =1, a letter to find and decode=3
' adding graphics effects
' main declares
Dim jokes$
(1 To 100) ' load jokes one time from data statements in program
_FullScreen 'I guess it does make it easier to tell E from F...
For i
= 1 To 100 'ready jokes 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)ReDim Worms
(1 To nWorms
) As Object
' clear old arrays NewWormYard 0, 0, Xmax, Ymax
resetWorms = -1
si = 0: lc = 0
HighLited = 1 'setup done start game
Mode = 0
DisplayInstructions '<< this part can be eaten by worms very bottom of drawing
Update ' need yellow and white to slow worms
DrawWorms resetWorms ' yellow and white not working???
lc = lc + 1
If si
< nSpiders
Then si
= si
+ 1: newSpinner si
drawSpinner S
(i
).X
, S
(i
).Y
, S
(i
).Sz
, _Atan2(S
(i
).DY
, S
(i
).DX
), S
(i
).C1
S(i).X = S(i).X + S(i).DX: S(i).Y = S(i).Y + S(i).DY
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
'Update ' on top of every thing sets color to mode
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 ")
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 ")
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
c$
= LCodes$
(Asc(k$
) - 64) Guesses$
(Asc(c$
) - 64) = k$
Mode = 0
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
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$
Mode = 0
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
25, String$(31, "W") ' for worm poison (the fore color) cp 24, " Select Code Letter or Menu # "
cp
25, String$(31, "W") ' for worm poison (the fore color) cp 24, " Select Letter to Find "
cp
25, String$(31, "W") ' for worm poison (the fore color)
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() If Timer - KeyTimer
>= 4 Then choice$
= Mid$(selection$
, Place
+ 1, 1): Place
= 0
show:
'_Display
Sub DrawWorms
(DrawReset
As Integer) ' one frame in main loop 'M = _Mem(x())
'_MemFill M, M.OFFSET, M.SIZE, 0 As _BYTE 'reset the array, Thanks Steve
'M = _Mem(y())
'_MemFill M, M.OFFSET, M.SIZE, 0 As _BYTE 'reset the array, eh didn't work
NewWorm i
x(i, j) = 0: y(i, j) = 0
DrawReset = 0
Fcirc Worms(i).X, Worms(i).Y, 6, &HFF000000
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
If Rnd < .15 Then 'move the worm (gots to slow down the worms) 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 Worms
(i
).DX
^ 2 + Worms
(i
).DY
^ 2 > 2 Then Worms(i).DX = Worms(i).DX * .5: 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 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
If x
(i
, j
) And y
(i
, j
) Then DrawBall x
(i
, j
), y
(i
, j
), 6, Worms
(i
).C1
DrawBall x(i, 1), y(i, 1), 6, Worms(i).C1
Sub NewWormYard
(x
, y
, w
, h
) WormYard.X = x: WormYard.Y = y: WormYard.W = w: WormYard.H = h
'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
)
Sub newSpinner
(i
As Integer) 'set Spinners dimensions start angles, color? S
(i
).DX
= (S
(i
).Sz
* Rnd * 2 + 2) * r
* 1.25: S
(i
).DY
= (S
(i
).Sz
* Rnd * 2 + 2) * r
* 1.25 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
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
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
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
S
(i
).C1
= _RGB32(r
, Rnd * .5 * r
, Rnd * .25 * r
) 'red ghost spiders???
Dim x1
, x2
, x3
, x4
, y1
, y2
, y3
, y4
, r
, a
, a1
, a2
, lg
, d
, rd
switch = switch + 2
switch
= switch
Mod 16 + 1 r = 10 * scale
x1
= x
+ r
* Cos(heading
): y1
= y
+ r
* Sin(heading
) r = 2 * r 'lg lengths
a
= heading
+ .9 * lg
* _Pi(1 / 5) + (lg
= switch
) * _Pi(1 / 10) a
= heading
- .9 * (lg
- 4) * _Pi(1 / 5) - (lg
= switch
) * _Pi(1 / 10) x2
= x1
+ r
* Cos(a
): y2
= y1
+ r
* Sin(a
) drawLink x1
, y1
, 3 * scale
, x2
, y2
, 2 * scale
, _RGB32(rred
+ 20, ggreen
+ 10, bblue
+ 5) x3
= x2
+ r
* 1.5 * Cos(a1
): y3
= y2
+ r
* 1.5 * Sin(a1
) drawLink x2
, y2
, 2 * scale
, x3
, y3
, scale
, _RGB32(rred
+ 35, ggreen
+ 17, bblue
+ 8) a2
= a1
+ d
* _Pi(1 / 8) * rd
/ 8 x4
= x3
+ r
* 1.5 * Cos(a2
): y4
= y3
+ r
* 1.5 * Sin(a2
) drawLink x3
, y3
, scale
, x4
, y4
, scale
, _RGB32(rred
+ 50, ggreen
+ 25, bblue
+ 12) r = r * .5
Fcirc x1
, y1
, r
, _RGB32(rred
- 20, ggreen
- 10, bblue
- 5) x2
= x1
+ (r
+ 1) * Cos(heading
- _Pi(1 / 12)): y2
= y1
+ (r
+ 1) * Sin(heading
- _Pi(1 / 12)) Fcirc x2, y2, r * .2, &HFF000000
x2
= x1
+ (r
+ 1) * Cos(heading
+ _Pi(1 / 12)): y2
= y1
+ (r
+ 1) * Sin(heading
+ _Pi(1 / 12)) Fcirc x2, y2, r * .2, &HFF000000
r = r * 2
x1
= x
+ r
* .9 * Cos(heading
+ _Pi): y1
= y
+ r
* .9 * Sin(heading
+ _Pi) TiltedEllipseFill
0, x1
, y1
, r
, .7 * r
, heading
+ _Pi, _RGB32(rred
, ggreen
, bblue
)
Dim a
, a1
, a2
, x3
, x4
, x5
, x6
, y3
, y4
, y5
, y6
x3
= x1
+ r1
* Cos(a1
): y3
= y1
+ r1
* Sin(a1
) x4
= x1
+ r1
* Cos(a2
): y4
= y1
+ r1
* Sin(a2
) x5
= x2
+ r2
* Cos(a1
): y5
= y2
+ r2
* Sin(a1
) x6
= x2
+ r2
* Cos(a2
): y6
= y2
+ r2
* Sin(a2
) fquad x3, y3, x4, y4, x5, y5, x6, y6, c
Fcirc x1, y1, r1, c
Fcirc x2, y2, r2, c
'need 4 non linear points (not all on 1 line) list them clockwise so x2, y2 is opposite of x4, y4
ftri x1, y1, x2, y2, x4, y4, c
ftri x3, y3, x4, y4, x1, y1, c
prc
= _RGB32(255, 255, 255, 255) mx2 = max + max
_Source tef
'point wont read without this! Line (lasti
, lastj
)-(i
, j
), prc
lasti = i: lastj = j
x = 0
x = x + 1
xleft(y) = x
x = x + 1
x = x + 1
If x
= mx2
Then xright
(y
) = xleft
(y
) Else xright
(y
) = x
If xleft
(y
) <> mx2
Then Line (xleft
(y
) + x0
- max
, y
+ y0
- max
)-(xright
(y
) + x0
- max
, y
+ y0
- max
), c
, BF
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
)