Posted: 18th Apr 2008 20:09
This is my code I want it to just allow you to enter one letter per guess. And for the enter guess to stay in place instead of repeating after each guess.
startprogram:
lu = 0
ec = 0
Cls
rem Create the Word List Array
dim words$(12)
words$(0) = "tea"
words$(1) = "rat"
words$(2) = "que"
words$(3) = "wow"
words$(4) = "fork"
words$(5) = "last"
words$(6) = "mint"
words$(7) = "play"
words$(8) = "rent"
words$(9) = "scene"
words$(10) = "brain"
words$(11) = "horse"
words$(12) = "zebra"
rem Random Timer
randomize timer()
Rem Randomize the Array
num = rnd(12)
ww$ = words$(num)
lw = len (ww$)
print ww$
Rem Pull up Functions
title()
gallows()
rem word length 3 spaces
if lw = 3
threespace()
else
rem word length 4 spaces
if lw = 4
fourspace()
else
rem word length 5 spaces
fivespace()
endif
endif
dim letters$(lw)
rem For Loop to get program to pick right amount of spaces for words
for c = 1 to lw
letters$(c) = mid$(ww$,c)
next c
rem guess
input "Guess ";guess$
rem to exit program
while guess$ <> "qq"
found = 0
rem first letter right
for ctr = 1 to lw
if guess$ = letters$(ctr) and ctr = 1
text 160,350, guess$
lu = lu + 1
found = 1
else
rem second letter right
if guess$ = letters$(ctr) and ctr = 2
text 200,350, guess$
lu = lu + 1
found = 1
else
rem third letter right
if guess$ = letters$(ctr) and ctr = 3
text 235,350, guess$
lu = lu + 1
found = 1
else
rem fourth letter right
if guess$ = letters$(ctr) and ctr = 4
text 270,350, guess$
lu = lu + 1
found = 1
else
rem fifth letter right
if guess$ = letters$(ctr) and ctr = 5
text 305,350, guess$
lu = lu + 1
found = 1
endif
endif
endif
endif
endif
next ctr
rem counter for you win plus randomize spots and colors
if lu = lw
sleep 500
cls
for ctr = 1 to 30
ink rgb (rnd(255),rnd(255),rnd(255)),0
text rnd (500),rnd (400), "You Win"
sleep 100
next ctr
goto startprogram
endif
rem bring up head if guess is wrong
if found <> 1 and ec = 0
head()
ec = ec +1
else
rem bring up body if guess is wrong
if found <> 1 and ec = 1
body()
ec = ec + 1
else
rem bring up rarm if guess is wrong
if found <> 1 and ec = 2
rarm()
ec = ec + 1
else
rem bring up larm if guess is wrong
if found <> 1 and ec = 3
larm()
ec = ec + 1
else
rem bring up rarm if guess is wrong
if found <> 1 and ec = 4
rleg()
ec = ec + 1
else
rem bring up lleg if guess is wrong
if found <> 1 and ec = 5
lleg()
ec = ec + 1
rem you lose
if ec = 6
sleep 500
cls
for ctr = 1 to 30
ink rgb (rnd(255),rnd(255),rnd(255)),0
text rnd (500),rnd (400), "You Lose. Your word was "+ww$+"."
sleep 100
next ctr
goto startprogram
endif
endif
endif
endif
endif
endif
endif
rem input guess
input "Guess ";guess$
endwhile
end
rem Function Section
rem Title Function
function title()
set text font "chiller"
set text size 60
ink rgb(0,0,255),0
text 200,100, "Welcome to Hangman!"
ink rgb(200,0,0),0
text 201,102, "Welcome to Hangman!"
endfunction
rem Gallows Function
function gallows()
line 300,200,400,200
line 400,200,400,375
line 350,375,450,375
line 300,200,300,230
endfunction
rem Head Function
function head()
circle 300,245,15
endfunction
rem Body Function
function body()
line 300,260,300,310
endfunction
rem Right Leg Function
function rleg()
line 300,310,280,350
endfunction
Rem Left leg Function
function lleg()
line 310,350,300,310
endfunction
rem Right Arm Function
function rarm()
line 300,280,280,320
endfunction
rem Left Arm Function
function larm()
line 300,280,325,320
endfunction
rem Three Space Function
function threespace()
line 160,400,195,400
line 200,400,230,400
line 235,400,265,400
endfunction
rem Four Space Function
function fourspace()
line 160,400,195,400
line 200,400,230,400
line 235,400,265,400
line 270,400,300,400
endfunction
rem Five Space Function
function fivespace()
line 160,400,195,400
line 200,400,230,400
line 235,400,265,400
line 270,400,300,400
line 305,400,335,400
endfunction