REM Project: week
REM Created: 3/21/2011 7:12:18 PM
REM By: Alfredo Di Nunzio
REM ***** Main Source File *****
REM
cls
dim wordlist(12) as string
num as integer
gitem as string
li as integer
wordlist(0) = "beach"
wordlist(1) = "point"
wordlist(2) = "space"
wordlist(3) = "table"
wordlist(4) = "back"
wordlist(5) = "nova"
wordlist(6) = "home"
wordlist(7) = "shot"
wordlist(8) = "note"
wordlist(9) = "sly"
wordlist(10) = "dad"
wordlist(11) = "pie"
wordlist(12) = "spy"
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
threeSpace()
fourSpace()
else
if li = 5
threeSpace()
fourSpace()
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
if letterWrong(guess)
errors = HandleError(errors)
endif
letterguess = 1
while guess<> "qq" and letterguess <=11
rem for words that are 5 letters
if li = 5
if guess = itemletters(1)
text 115,380, guess
usedletters = usedletters + 1
endif
if guess = itemletters(2)
text 170,380, guess
usedletters = usedletters + 1
endif
if guess = itemletters(3)
text 215,380, guess
usedletters = usedletters + 1
endif
if guess = itemletters(4)
text 265,380, guess
usedletters = usedletters + 1
endif
if guess = itemletters(5)
text 305, 380, guess
usedletters = usedletters + 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
endif
if guess = itemletters(2)
text 170,380, guess
usedletters = usedletters + 1
endif
if guess = itemletters(3)
text 215,380, guess
usedletters = usedletters + 1
endif
if guess = itemletters(4)
text 265,380, guess
usedletters = usedletters + 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
endif
if guess = itemletters(2)
text 170,380, guess
usedletters = usedletters + 1
endif
if guess = itemletters(3)
text 215,380, guess
usedletters = usedletters + 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
remstart
if wrongletters = 1
head()
endif
if wrongletters = 2
body()
endif
if wrongletters = 3
rleg()
endif
if wrongletters = 4
lleg()
endif
if wrongletters = 5
rarm()
endif
if wrongletters = 6
larm()
endif
remend
letterguess = letterguess + 1
if letterguess < 12
input "Guess a letter or press QQ to quit: ", guess
else
print "Out of guesses, you lose!"
endif
endwhile
wait key
remstart
head()
wait key
body()
wait key
rleg()
wait key
lleg()
wait key
rarm()
wait key
larm()
wait key
threeSpace()
wait key
fourSpace()
wait key
fiveSpace()
wait key
remend
end
function title()
set text font "Courier"
set text size 36
ink rgb(0,255,0),0
text 120,40, "Welcome To Hang-Man!"
ink rgb(255,0,0),0
text 122,42, "Welcome To Hang-Man!"
set text size normal
ink rgb(0,255,0),0
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 250,400,280,400
endfunction
function fiveSpace()
line 300,400,330,400
endfunction
function LetterWrong(sLetter$)
bOutput as boolean = 1
for c = 1 to array count(itemletters(0))
if itemletters(c) = sLetter$
bOutput = 0
exit
endif
next c
endfunction bOutput
function HandleError(errors)
inc errors
select errors
case 1
head()
endcase
case 2
body()
endcase
case 3
rleg()
endcase
case 4
lleg()
endcase
case 5
rarm()
endcase
case 6
larm()
endcase
endselect
endfunction errors
wait key
end
Here is all my code. It is quite messy as i am new to programming but trying my best, unfortunately this is all due for me in a few hours so hopefully I can get this done before then.
I tried what you said and it worked for 1 error being the head, but after two errors it does not do anything else, not quite sure what i am missing.