Heeelp.
Hangman is hurting. He needs to know how to use a letter once and only once.
cls
remstart
1. A thirteen element array for the words to be used in your hangman program.
2. A way to randomly select the word from the word list.
3. A way to get the length of the randomly selected word.
4. An "if statement" that will display the appropriate number of letter spaces under it.
5. Create and fill a variable length element array with the letters of the word that was
randomly selected.
6. Display the game title. Done
7. Display your gallows. Done
remend
rem Build an array with 13 words.
rem Four, three letter words, five, four letter words & four five letter words.
Dim word$(12)
word$(0)= "pen"
word$(1)= "urn"
word$(2)= "ski"
word$(3)= "sat"
word$(4)= "test"
word$(5)= "bait"
word$(6)= "rate"
word$(7)= "quit"
word$(8)= "lake"
word$(9)= "grate"
word$(10)= "scars"
word$(11)= "skean"
word$(12)= "grope"
number = random()
rem Identify number generated
rem print number
letter$=word$(number)
rem print length
rem print letter$
rem visually see word to compare with number generated and it's match in the array.
rem text 100, 100, word$(number)
rem compute length of word
length = len (letter$)
Rem pass the randomly selected word into working variable
rem display$ = word$(number)
Rem Create a variable element array to contain the letters of the item ramdomly selected. We
Rem will use the value in spaces(length) to determine the number of elements within the array.
dim itemletters$(length)
for c = 1 to length
itemletters$(C) = Mid$(letter$,c)
print itemletters$(c)
next c
if length = 3
threespace()
else
if length =4
fourspace()
else
fivespace()
endif
endif
Rem Display the title.
Title()
Rem Display the gallows.
gallows()
input "Guess a letter ",guess$
while guess$ <> "qq"
for d=1 to length
if guess$ = itemletters$(d) and d=1
text 135,425, guess$
letterguess = letterguess+1
else
if guess$ = itemletters$(d) and d=2
text 185,425, guess$
letterguess = letterguess+1
else
if guess$ = itemletters$(d) and d=3
text 235,425, guess$
letterguess = letterguess+1
else
if guess$ = itemletters$(d) and d=4
text 285,425, guess$
letterguess = letterguess+1
else
if guess$ = itemletters$(d) and d=5
text 335,425, guess$
letterguess = letterguess+1
endif
endif
endif
rem Print the you win message.
if letterguess = length
youwin()
endif
endif
rem Print the you win message.
if letterguess = length
youwin()
endif
endif
rem Print the you win message.
if letterguess = length
youwin()
endif
next
input "Guess a letter ",guess$
endwhile
rem This ends the program and must be present before the function declarations
end
function Title()
rem Define the font, size of title. Identifies game title name.
set text font "comic sans ms"
set text size 36
ink rgb(0, 255, 0), 0
text 120, 40, "Welcome to Hang-Man"
ink rgb(255, 0, 0), 0
text 120, 42, "Welcome to Hang-Man"
set text size normal
ink rgb(0, 255, 0), 0
endfunction
function gallows()
rem Draw post
line 175, 125, 175, 375
rem draw bar
line 175, 125, 275, 125
rem draw rope
line 275, 125, 275, 175
endfunction
function head()
rem draw the head
circle 275, 190, 15
endfunction
function body()
line 275, 205, 275, 260
endfunction
function lleg()
rem Draw left leg
line 275, 260, 300, 310
endfunction
function rleg()
rem Draw right leg
line 275, 260, 250, 310
endfunction
function larm()
rem Draw left arm
line 275, 205, 300, 245
endfunction
function rarm()
rem Draw right arm
line 275, 205, 250, 245
endfunction
function threespace()
rem 1st letter space
Line 125, 450, 150, 450
rem 2nd letter space
Line 175, 450, 200, 450
rem 3rd letter space
Line 225, 450, 250, 450
endfunction
function fourspace()
rem 1st letter space
Line 125, 450, 150, 450
rem 2nd letter space
Line 175, 450, 200, 450
rem 3rd letter space
Line 225, 450, 250, 450
rem 4th letter space
Line 275, 450, 300, 450
endfunction
function fivespace()
rem 1st letter space
Line 125, 450, 150, 450
rem 2nd letter space
Line 175, 450, 200, 450
rem 3rd letter space
Line 225, 450, 250, 450
rem 4th letter space
Line 275, 450, 300, 450
rem 5th letter space
Line 325, 450, 350, 450
endfunction
function random()
rem Number generator for chose a word at random
randomize timer()
number = rnd(12)
endfunction number
function youwin()
cls
for win=1 to rnd(450)
text rnd(450), rnd(450), "you Win"
next win
endfunction