Well i figured out arrays abit and added one in. I added a new function which checksprevious letter and should work...
function checkprevious()
dim alphabet$(25)
data "a","b","c","d","e","f","g","h","i","j","k","l",
data "m","n","o","p","q","r","s","t","u","v","w","x","y","z",
for c = 0 to 25
If guess$ = mid$(alphabet$,c)
usedletters$ = usedletters$ + guess$
lettersused = lettersused + 1
endif
next c
for c = 0 to lettersused
If guess$ = mid$(usedletters$,c)
set cursor 200,500,
Print " "
set cursor 200,500,
Print "Do not repeat Same Letter"
wait 1500
Set cursor 200,500,
Print " "
Set cursor 200,500,
gosub checking
endif
next c
endfunction
and the full source code:
#constant screenwidth = 800
#constant screenheight = 600
#constant fontname = "Courier New"
#constant fontsize = 30
#constant fontcolour = RGB(0,0,255)
Global word$
global guess$
global definition$
global wrongguesses
global correctletters
global previousguess$
global usedletters$
global lettersused
REM MAIN PROGRAM
Initialisegame()
Thinkofword()
Drawinitialscreen()
Repeat
lettersused = 0
checking:
Getguess()
checkprevious()
letterfound = checkforletter()
If letterfound = 1
Drawletter()
Else
Addtohangedman()
Endif
Until Wordguessed() = 1
Wait key
end
Function Initialisegame()
hide mouse
Set display mode screenwidth,screenheight,16
set text font fontname
set text size fontsize
ink fontcolour,0
wrongguesses = 0
correctletters = 0
Randomize timer()
endfunction
Function Thinkofword()
Data "london","city","here",
Data "athen","john","work",
Data "nose","date","time","clock","spoon",
Data "what","math","add","zebra",
Data "yes","cats",
num =rnd(18)+1
For c = 1 TO num
Read Definition$
Next c
Endfunction
Function DrawinitialScreen()
Set Cursor 300,80
Print "H A N G M A N"
Drawgallows()
Drawhyphens()
Endfunction
Function Drawgallows()
Box 50,500,150,550
Line 60,500,60,300
Line 60,300,150,300
Line 150,300,150,350
Endfunction
Function DrawHyphens()
Set Cursor 250,400
For c = 1 to len(definition$)
Print "_ ";
next c
Endfunction
Function Getguess()
Set text opaque
set cursor 200,500,
Print " ";
Set Cursor 200,500,
Print " "
Input "Enter your guess: ",guess$
guess$ = lower$(guess$)
while len(guess$)<>1 or guess$<"a" or guess$>"z"
Set Cursor 200,500,
Print " "
set cursor 200,500,
Print "Single Letters Only"
wait 1000
Print " "
set cursor 200,500,
Input "Enter your guess: ",guess$
guess$ = Lower$(guess$)
Endwhile
set text transparent
endfunction
function checkforletter()
letterfound=0
for c = 1 to len(definition$)
If guess$ = mid$(definition$,c)
checkprevious()
previousguess$ = guess$
letterfound = 1
correctletters = correctletters + 1
endif
next c
If letterfound = 0
checkprevious()
previousguess$ = guess$
wrongguesses = wrongguesses + 1
endif
endfunction letterfound
function drawletter()
set cursor 250,400
Repeat c = 1
if guess$= mid$(definition$,c)
Print Upper$(guess$)," ";
else
print " ";
endif
c = 2
Until c = 2
for c = 2 to len(definition$)
if guess$= mid$(definition$,c)
Print guess$," ";
else
print " ";
endif
next c
endfunction
function addtohangedman()
select wrongguesses
case 1
circle 150,360,10
endcase
case 2
ellipse 150,400,10,30
endcase
case 3
line 145,428,135,460
endcase
case 4
line 155,428,165,460
endcase
case 5
line 157,380,167,410
endcase
case 6
line 143,380,133,410
gameover()
endcase
endselect
endfunction
function wordguessed()
if correctletters = len(definition$)
set cursor 330,200
Print " YOU WON "
wait 1000
exitfunction 1
endif
endfunction 0
Function gameover()
set cursor 330,200
print "game over"
wait key
end
endfunction
function checkprevious()
dim alphabet$(25)
data "a","b","c","d","e","f","g","h","i","j","k","l",
data "m","n","o","p","q","r","s","t","u","v","w","x","y","z",
for c = 0 to 25
If guess$ = mid$(alphabet$,c)
usedletters$ = usedletters$ + guess$
lettersused = lettersused + 1
endif
next c
for c = 0 to lettersused
If guess$ = mid$(usedletters$,c)
set cursor 200,500,
Print " "
set cursor 200,500,
Print "Do not repeat Same Letter"
wait 1500
Set cursor 200,500,
Print " "
Set cursor 200,500,
gosub checking
endif
next c
endfunction