Quote: "when correct answers are made, the hangman persists to be drawn"
The reason for this is you weren't setting the variable "found" to 1 (or something other than 0) when the player guessed a letter correctly.
So at the line:
if found = 0 and error = 0
found was always equal to 0 so the program will always draw the stick man no matter what the player does.
I've modified your code to correct this:
Edit: code modified to show correct indenting
cls
dim wordlist(12) as string
num as integer
gitem as string
li as integer
wordlist(0) = "actor"
wordlist(1) = "craze"
wordlist(2) = "flask"
wordlist(3) = "hunch"
wordlist(4) = "pulp"
wordlist(5) = "nova"
wordlist(6) = "hood"
wordlist(7) = "slat"
wordlist(8) = "nine"
wordlist(9) = "fly"
wordlist(10) = "pig"
wordlist(11) = "pie"
wordlist(12) = "tie"
randomize timer()
title()
gallows()
wait key
num = rnd(12)
gitem$ = wordlist(num)
print gitem$
li = len(gitem$)
if li = 3
threeSpace()
else
if li = 4
fourSpace()
else
if li = 5
fiveSpace()
else
endif
endif
endif
dim itemletters(li) as string
for c = 1 to li
itemletters(c) = mid$(gitem$,c)
next c
guess as string
usedletters as integer
letterguess as integer
wrongletters as integer = 0
winner as string = "You Win!"
errors = 0
found as integer = 0
input "Guess a letter or press qq to quit: ", guess
guess$=lower$(guess$)
letterguess = 1
while guess <> "qq"
`SET FOUND TO ZERO BEFORE EACH GUESS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
found = 0
rem for words that are 5 letters
if li = 5
if guess = itemletters(1)
text 115,380, guess
usedletters = usedletters + 1
`IF THE PLAYER GUESSES CORRECTLY SET FOUND TO 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
found = 1
endif
if guess = itemletters(2)
text 170,380, guess
usedletters = usedletters + 1
found = 1
endif
if guess = itemletters(3)
text 215,380, guess
usedletters = usedletters + 1
found = 1
endif
if guess = itemletters(4)
text 265,380, guess
usedletters = usedletters + 1
found = 1
endif
if guess = itemletters(5)
text 305, 380, guess
usedletters = usedletters + 1
found = 1
endif
if usedletters = 5
cls
loopc = 1
while loopc < 30
text rnd(500), rnd(350), winner
loopc = loopc + 1
endwhile
wait key
end
endif
endif
rem for words that are 4 letters
if li = 4
if guess = itemletters(1)
text 115,380, guess
usedletters = usedletters + 1
found = 1
endif
if guess = itemletters(2)
text 170,380, guess
usedletters = usedletters + 1
found = 1
endif
if guess = itemletters(3)
text 215,380, guess
usedletters = usedletters + 1
found = 1
endif
if guess = itemletters(4)
text 265,380, guess
usedletters = usedletters + 1
found = 1
endif
if usedletters = 4
cls
loopc = 1
while loopc < 30
text rnd(500), rnd(350), winner
loopc = loopc + 1
endwhile
wait key
end
endif
endif
rem for words that are 3 letters
if li = 3
if guess = itemletters(1)
text 115,380, guess
usedletters = usedletters + 1
found = 1
endif
if guess = itemletters(2)
text 170,380, guess
usedletters = usedletters + 1
found = 1
endif
if guess = itemletters(3)
text 215,380, guess
usedletters = usedletters + 1
found = 1
endif
if usedletters = 3
cls
loopc = 1
while loopc < 30
text rnd(500), rnd(350), winner
loopc = loopc + 1
endwhile
wait key
end
endif
endif
if found = 0 and error = 0
head()
error = error + 1
else
if found = 0 and error = 1
body()
error = error + 1
else
if found = 0 and error = 2
larm()
error = error + 1
else
if found = 0 and error = 3
rarm()
error = error + 1
else
if found = 0 and error = 4
lleg()
error = error + 1
else
if found = 0 and error = 5
rleg()
error = error + 1
endif
endif
endif
endif
endif
endif
if error = 6
cls
for c = 1 to 30
sleep 250
text rnd(580), rnd(400), "Out of guesses, you lose!"
next c
endif
letterguess = letterguess + 1
if letterguess < 12
input "Guess a letter or press QQ to quit: ", guess
else
endif
endwhile
wait key
end
function title()
set text font "cambria"
set text size 20
ink rgb(255,0,0),0
center text 300,20, "Welcome to Hangman!"
ink rgb(0,0,255),0
center text 301,21, "Welcome to Hangman!"
endfunction
function gallows()
line 200,100,200,320
line 200,100,300,100
line 300,100,300,150
endfunction
function head()
circle 300,160,10
endfunction
function body()
line 300,172,300,210
endfunction
function rleg()
line 300,210,290,250
endfunction
function lleg()
line 300,210,310,250
endfunction
function rarm()
line 300,172,310,210
endfunction
function larm()
line 300,172,290,210
endfunction
function threeSpace()
line 100,400,130,400
line 150,400,180,400
line 200,400,230,400
endfunction
function fourSpace()
line 100,400,130,400
line 150,400,180,400
line 200,400,230,400
line 250,400,280,400
endfunction
function fiveSpace()
line 100,400,130,400
line 150,400,180,400
line 200,400,230,400
line 250,400,280,400
line 300,400,330,400
endfunction
You'll also notice that I've indented the code how I would indent it, as Hogey stated this makes the code easier to read. I've also added in a bit of white space (blank lines) for the same reason. You could also do with a bit more commenting.
As for the other stuff you've been criticized for, I agree with Hogey when using inc and dec instead of "variable = variable + 1" it's a matter of preference, although I have a feeling inc and dec are faster (someone correct me if I'm wrong). I also think that using INPUT and PRINT commands are useful for a beginner as I think they're nice and easy to use (just my thought on the topic). I don't think either of these two are particularly criminal.
If I was going to criticize anything, I think your approach is a bit brute force and you're not using the arrays in a particulary clever way. For instance this:
if guess = itemletters(1)
text 115,380, guess
usedletters = usedletters + 1
found = 1
endif
if guess = itemletters(2)
text 170,380, guess
usedletters = usedletters + 1
found = 1
endif
if guess = itemletters(3)
text 215,380, guess
usedletters = usedletters + 1
found = 1
endif
if guess = itemletters(4)
text 265,380, guess
usedletters = usedletters + 1
found = 1
endif
if guess = itemletters(5)
text 305, 380, guess
usedletters = usedletters + 1
found = 1
endif
can be rewritten like this:
for i = 1 to 5
if guess = itemletters(i)
text 70+i*45,380, guess
usedletters = usedletters + 1
found = 1
endif
next i
You might want to look at the SELECT... CASE... ENDCASE... ENDSELECT commands as this might tidy up your nested if statements and you might want to look at either the DATA command or reading from external files for the list of words.
Quote: "... I need the program to be able to be replayed..."
This is all a matter of structure and having loops within loops. It would look something like this (a crude bit of psuedo code so don't try to run this):
set anything that won't be changed at the start of the program or anything that you need to set before the game starts: ie
fastest race time set to a high time (or read from a save file)
highest score set to zero (or read read from a save file)
START MAIN LOOP
here you'll have anything that needs to be set in order to play the game such as:
player health set to maximum
ammo count set to starting value
score set to zero
number of guesses set to zero
race time set to zero
START GAME LOOP
this is the loop where the game will be played, where things will change, ie:
player health decreases when player is hit, increases when they collect health packs
ammo count decrease as the player shoots, increase if they collect ammo pack
score increase as they hit enemies
number of guesses increase as they player makes guesses
race time increase as the player races around the track
END MAIN LOOP
at this point you may want to set new highest score etc.
give the player an option to play again or quit
END MAIN LOOP
You might also want to look at some of the games on the 20 line challenge board, as they might have a replay option (I know mine do) and have expanded easy to read versions.
Hope this helps.