Okay, this is reeeeaaaaally embarrassing, but I thought it would amuse ya'll
I got up this morning and remembered I'd posted some info in this thread so I whipped up an example code... And then got carried away - as usual since I cannot live life but by extremes and " 'overboard' string cannot be found in 'nonZero.dic' ".
So here's the extremist program. It hasn't a wordlist but that's fine, just change the "todaysword$" variable. It's easy enough to build a wordlist in.
remstart
Hangman - nonZero style
'Tis a wonerful game in which you are rewarded for guessing the right word
but also for getting it wrong as you see a low quality model be hanged
Default word is "mobility"
remend
`Constant make life easy without wastin memory
#CONSTANT lstand 1
#CONSTANT rstand 2
#CONSTANT mstand 3
#CONSTANT crossbeam 4
#CONSTANT supportbeam 5
#CONSTANT rope 6
#CONSTANT head 7
#CONSTANT neck 8
#CONSTANT hbody 9
#CONSTANT larm 10
#CONSTANT rarm 11
#CONSTANT lleg 12
#CONSTANT rleg 13
#CONSTANT constdist 20
`First setup variables we'll be using
GLOBAL wrong = 0
GLOBAL todaysword$ = "mobility"
GLOBAL curword$ = ""
GLOBAL halfx
GLOBAL halfy
GLOBAL gamestatus = 0
`See, we need but 1 array
DIM guessed(26)
`Setup Display
SET DISPLAY MODE DESKTOP WIDTH(), DESKTOP HEIGHT(), 32
halfx = SCREEN WIDTH() / 2: halfy = SCREEN HEIGHT() / 2
AUTOCAM OFF
SYNC RATE 60
POSITION CAMERA 0, 0,0,0
ROTATE CAMERA 0, 0,0,0
COLOR BACKDROP 0x000000
`Initialisation procedures
MakeMan()
FOR i = 1 TO LEN(todaysword$): curword$ = curword$ + "_": NEXT i
`Main loop
WHILE gamestatus < 3
RenderGFX()
IF SCANCODE() > 0: GetInput(): ENDIF
IF gamestatus = 1: Winner(): WHILE SCANCODE() > 0: ENDWHILE: CLEAR ENTRY BUFFER: ENDIF
IF gamestatus = 2: Loser(): WHILE SCANCODE() > 0: ENDWHILE: CLEAR ENTRY BUFFER: ENDIF
ENDWHILE
END
Function CheckWords()
`Quick check
IF UPPER$(curword$) = UPPER$(todaysword$)
gamestatus = 1
ENDIF
EndFunction
Function Error(ernum)
`Display an error message.
IF ernum = 1: msg$ = "Invalid character. Letters range from A-Z!": ENDIF
IF ernum = 2: msg$ = "You already chose that letter!": ENDIF
DO
CENTER TEXT halfx, halfy, msg$
CENTER TEXT halfx, halfy + 60, "Press ENTER to continue..."
IF RETURNKEY() = 1: EXIT: ENDIF
LOOP
EndFunction
Function GetInput()
`This just grabs a player's inout. One of many ways of doing it but I thought I'd
`showcase the use of the windows entry buffer since you've seen INKEY$() and KEYSTATE()
`in enough other examples.
guessletter$ = UPPER$(LEFT$(ENTRY$(1), 1)) `Why use LEFT$? To ensure that the first letter pressed is used.
tmp = ASC(guessletter$) - 64 `Okay, kinda sneaky. Get the ASCII value - 64 ("A" = 65).
IF tmp > 26 OR tmp < 1
Error(1) `If outta range (not a - z), display error message.
ELSE
IF guessed(tmp) = 1 `That's sneaky, I know but whatever works. So if it has been guessed already
Error(2) `then yell at player.
ELSE
guessed(tmp) = 1 `Assign the value. NOW,
tempword$ = UPPER$(todaysword$) `For easiness sake
wrongguess = 1 `If a correct guess was made, this will be conditionally changed later.
curword$ = "" `Reset current word (the word the user is making).
FOR i = 1 TO LEN(tempword$) `Now we run a check but kill two bird (updating word and checkin input) with one stone
addspace = 1 `Much the same as "wrongguess".
FOR b = 1 TO 26
IF guessed(b) = 1 `We're checking to see what letters were guessed (have a value of 1)
IF ASC(MID$(tempword$, i)) - 64 = b `If this round was a hit,
addspace = 0 `Don't add a space to our user's string (curword$)
ENDIF
ENDIF
NEXT b
IF addspace = 1 `If we had no hits, add the space,
curword$ = curword$ + "_"
ELSE
curword$ = curword$ + MID$(tempword$, i) `Otherwise, add the letter.
ENDIF
IF guessletter$ = MID$(tempword$, i): wrongguess = 0: ENDIF `If at any point the guessed letter matches our current letter from today's word, then wrong guess is false
NEXT i
IF wrongguess = 1: Hang(): ENDIF `If wrong guess was true, hang 'em som more
CheckWords() `Check the word to see if play won (pun)
ENDIF
ENDIF
WHILE SCANCODE() > 0: RenderGFX(): ENDWHILE `Halt program until player realeases keys (stops double-typing
CLEAR ENTRY BUFFER `Clear the entry buffer
EndFunction
Function Hang()
`Hang the player, track wrong guesses, do incredible thing, save 50% now!!
INC wrong `If this was called, we know to kill player a little more each time
SELECT wrong
CASE 1
SHOW OBJECT lstand
ENDCASE
CASE 2
SHOW OBJECT rstand
ENDCASE
CASE 3
SHOW OBJECT mstand
ENDCASE
CASE 4
SHOW OBJECT crossbeam
SHOW OBJECT supportbeam
ENDCASE
CASE 5
SHOW OBJECT rope
ENDCASE
CASE 6
SHOW OBJECT head
ENDCASE
CASE 7
SHOW OBJECT hbody
SHOW OBJECT neck
ENDCASE
CASE 8
SHOW OBJECT larm
ENDCASE
CASE 9
SHOW OBJECT rarm
ENDCASE
CASE 10
SHOW OBJECT lleg
ENDCASE
CASE 11
SHOW OBJECT rleg
ENDCASE
ENDSELECT
IF wrong = 11: gamestatus = 2: ENDIF
EndFunction
Function Loser()
`If player won
COLOR BACKDROP RGB(180,0,0)
done = 0
WHILE done = 0
CENTER TEXT halfx, halfy, "YOU HAVE LOSE THIS GAME!"
CENTER TEXT halfx, halfy + 40, "Press 1 to go again."
CENTER TEXT halfx, halfy + 60, "Press 2 to quit."
IF KEYSTATE(2) = 1: ResetAll(): gamestatus = 0: done = 1: ENDIF
IF KEYSTATE(3) = 1: ResetAll(): gamestatus = 3: done = 1: ENDIF
ENDWHILE
EndFunction
Function MakeMan()
`Make the hanged man
MAKE OBJECT BOX lstand, 2, 0.5, 0.5
ROTATE OBJECT lstand, 0, 0, 45
POSITION OBJECT lstand, -10, -2, constdist
MAKE OBJECT BOX rstand, 2, 0.5, 0.5
ROTATE OBJECT rstand, 0, 0, -45
POSITION OBJECT rstand, -8.8, -2, constdist
MAKE OBJECT BOX mstand, 12, 0.5, 0.5
ROTATE OBJECT mstand, 0, 0, 90
POSITION OBJECT mstand, -9.4, 4.5, constdist
MAKE OBJECT BOX crossbeam, 12, 0.5, 0.5
ROTATE OBJECT crossbeam, 0, 0, 0
POSITION OBJECT crossbeam, -3.65, 10.5, constdist
MAKE OBJECT BOX supportbeam, 2, 0.5, 0.5
ROTATE OBJECT supportbeam, 0, 0, 45
POSITION OBJECT supportbeam, -8.7, 9.7, constdist
MAKE OBJECT CYLINDER rope, 0.5
ROTATE OBJECT rope, 0, 0, 0
SCALE OBJECT rope, 5, 600, 5
POSITION OBJECT rope, 2, 9.25, constdist
MAKE OBJECT SPHERE head, 1, 30, 30
ROTATE OBJECT head, 0, 0, 90
POSITION OBJECT head, 2, 8, constdist
MAKE OBJECT CYLINDER neck, 0.5
ROTATE OBJECT neck, 0, 0, 0
SCALE OBJECT neck, 50, 150, 50
POSITION OBJECT neck, 2, 7.5, constdist + 0.1
MAKE OBJECT BOX hbody, 2.5, 3, 1
ROTATE OBJECT hbody, 0, 0, 0
SCALE OBJECT hbody, 50, 90, 50
POSITION OBJECT hbody, 2, 5.8, constdist
MAKE OBJECT BOX larm, 2.5, 0.4, 0.4
ROTATE OBJECT larm, 0, 0, -115
POSITION OBJECT larm, 1.0, 5.9, constdist - 0.05
CLONE OBJECT rarm, larm, 1
ROTATE OBJECT rarm, 0, 0, 115
POSITION OBJECT rarm, 3.0, 5.9, constdist - 0.05
MAKE OBJECT BOX lleg, 3, 0.4, 0.4
ROTATE OBJECT lleg, 0, 0, -95
POSITION OBJECT lleg, 1.5, 3.0, constdist
CLONE OBJECT rleg, lleg, 1
ROTATE OBJECT rleg, 0, 0, 95
POSITION OBJECT rleg, 2.5, 3.0, constdist
`Hide objects
FOR i = 1 TO 13: HIDE OBJECT i: NEXT i
EndFunction
Function RenderGFX()
`Have everything rendered in one function!
CENTER TEXT halfx, halfy + 60, curword$
CENTER TEXT halfx, halfy, "Guess a letter!"
EndFunction
Function ResetAll()
`Travel back in time
FOR i = 1 TO 13: HIDE OBJECT i: NEXT i
wrong = 0
curword$ = ""
FOR i = 1 TO 26: guessed(i) = 0: NEXT i
FOR i = 1 TO LEN(todaysword$): curword$ = curword$ + "_": NEXT i
COLOR BACKDROP 0x000000
EndFunction
Function Winner()
`If player won
COLOR BACKDROP 0x0000FF
done = 0
WHILE done = 0
CENTER TEXT halfx, halfy, "YOU HAVE WONNED THE GAME!"
CENTER TEXT halfx, halfy + 40, "Press 1 to go again."
CENTER TEXT halfx, halfy + 60, "Press 2 to quit."
IF KEYSTATE(2) = 1: ResetAll(): gamestatus = 0: done = 1: ENDIF
IF KEYSTATE(3) = 1: ResetAll(): gamestatus = 3: done = 1: ENDIF
ENDWHILE
EndFunction
Quote: "Vegeta, what's the scouter say about his overboard level?"
Quote: "IT'S OVER 9000!!!"
Heh, yeah.
PS: If anything doesn't make sense ask!
PPS: If anyone sees some problems with my code, pleeeez correct me, I wanna level up some more still.
[EDIT] Wow, I was half asleep this morning. Was looking over everything I did today and stumbled upon this example I brewed up. Heh, my "EEEEEE" line was still in the code
(I just mark places I'm gonna put messages and add the messages post-code with quickies). Ya know this really is over-board, lol. All I meant to do was illustrate what I meant in my post last night. Should've actually checked the thread properly this morning before making that program as I see Hodgey already posted some code. But after all hat effort, I had to share this wierd take on hangman. Anyway edited out the bad line. Might even edit this post in the future, depends. Just thinking it's pretty ironic I made it with 3D considering the original game was played with a pen and paper. Just remembering that makes me feel old...[/EDIT]