'===========================================================================
' Subject: HANGMAN                            Date: 06-18-96 (13:51)       
'  Author: John Wantland                      Code: QB, QBasic, PDS        
'  Origin: kwantlan@coffey.com              Packet: GAMES.ABC
'===========================================================================
REM hangman
RANDOMIZE TIMER
e = 21   'change if you add words
DIM word$(e)
' You can add you own words with data statements
' Be sure to change the first data statement if you do, though
SCREEN 12: CLS
s = 0
0 WIDTH 80, 60
CLS
GOSUB 1
DO
LOCATE i, u: PRINT b$
LOCATE 53, 1: PRINT "Word: "; m$
LOCATE 55, 1: PRINT "Score:"; s
LOCATE 56, 1: PRINT "Type in a letter(lower-case)."
slow: b$ = INKEY$: IF b$ = "" THEN GOTO slow
GOSUB check
IF m$ = word$(j) THEN GOTO win
u = u + 2: IF u > 10 THEN u = 1: i = i + 1
LOOP
1 PRINT "                                     Hangman"
PRINT "                                  by John Wantland"
PRINT
PRINT
PRINT "The object of the game is to guess the computer's word."
PRINT "If you miss, a part of the picture will be added on, and "
PRINT "you will have one less guess before you lose. If the"
PRINT "picture is completed, the game is over and you have to "
PRINT "start over. But, if you guess the word before then, you get"
PRINT "one point added to your score. Be careful not to use the same"
PRINT "letter twice, because it will be counted as another guess."
6 PRINT "Press a key to start."
i = 40
b$ = ""
u = 1
g = 0
2 a$ = INKEY$: IF a$ = "" THEN 2
m$ = ""
FOR j = 1 TO e
READ word$(j)
NEXT j
j = INT(RND * e + 1)
t = LEN(word$(j))
FOR k = 1 TO t
m$ = m$ + "_"
NEXT k
CLS
RETURN
3 CIRCLE (320, 100), 50
IF g = 1 THEN RETURN
LINE (320, 150)-(320, 350)
IF g = 2 THEN RETURN
LINE (320, 350)-(250, 450)
IF g = 3 THEN RETURN
LINE (320, 350)-(390, 450)
IF g = 4 THEN RETURN
LINE (320, 225)-(200, 200)
IF g = 5 THEN RETURN
LINE (320, 225)-(440, 200)
IF g = 6 THEN RETURN
CIRCLE (300, 80), 5
IF g = 7 THEN RETURN
CIRCLE (340, 80), 5
GOSUB new
RETURN
check:
x = 0
FOR k = 1 TO LEN(m$)
IF MID$(word$(j), k, 1) = b$ THEN MID$(m$, k, 1) = b$: x = 1
NEXT k
IF x = 1 THEN RETURN
g = g + 1
GOSUB 3
RETURN
new: CLS
INPUT "You lose. Play again"; y$
IF y$ = "y" OR y$ = "Y" THEN RESTORE: RUN:  ELSE END
RETURN
win: CLS
PRINT "You won this round.": s = s + 1
RESTORE
RESTORE
GOTO 0
' start of words
DATA kalamazoo
DATA ocean
DATA house
DATA rocket
DATA boat
DATA jeopardy
DATA notable
DATA diary
DATA tunnel
DATA train
DATA reporter
DATA pencil
DATA hammer
DATA nothing
DATA board
DATA bored
DATA retreat
DATA weights
DATA scale
DATA musical
DATA slimy
