hi im doing a hangman game on delphi and need to randomly choose a word from an array then every letter guessed by the user for the game to check if the letter is in the word n if so place it in the appropriate place and if not build a part of the gallows.. this is wat i have so far:
var NumberOfErrors, NumberOfLetters, NumberFound, time, count, setLength: integer;
ComputerWord, usersword: string;
found: boolean;
Randomize;
ComputerWord:= (Easywords);
NumberOfLetters:= length (ComputerWord);
setLength:= (usersword) NumberOFLetters);
WordLbl.Caption:= '';
NumberFound:= 0;
NumberOfErrors:= 0;
for count:= 1 to NumberOfLetters do
if ComputerWord [count] = key then
Begin
found:= true;
usersword [count] := key;
end;
procedure CheckIfCharacterInComputerWord (Sender: TObject);
Begin
NumberFound:= 0;
for count:= 1 to NumberOfLetters do
if Usersword [count] = key then
Begin
found:= true;
usersword:= key;
end;
procedure CountNumberFound (Sender:TObject);
Begin
NumberFound:= 0;
for count:= NumberOfLetters do
if Usersword [count] <> '?'
then NumberFound:= NumberFound + 1;
end;
Begin
wordLbl.caption:= '';
for count:= 1 to length (usersword) do
wordLbl.caption:= WordLbl.caption + Usersword [count] + '';
end;
Begin
NumberOfErrors:= NumberOFErrors + 1;
ImageHangman.Picture.LoadFromFile ('ImageEasy' + IntToStr (NumberOfErrors) + '.bmp');