
-----------------------------------
C00733
Thu Jun 01, 2006 8:28 pm

Hang Man!!!!!!
-----------------------------------
I'm trying to figure out how to put out the alphabet and then cross out the letters they chose. Please give some pointers!!!!!!!!!! I also want to know how to keep an array of words!!! I also need help on how to keep track of how many guesses they take!!! 

%%%%%%%%%%%%%%%%%%%%%% 
%Variable Decloration% 
%%%%%%%%%%%%%%%%%%%%%% 

var word : string %variable for the word 
var guess : string %their guess 
var s : int %to find out if they guessed a letter in the word 
word := "shark" % the word they have to guess 

%%%%%%%%%%%%%%%%%%%%%%% 
%%%Main Body Program%%% 
%%%%%%%%%%%%%%%%%%%%%%% 

put "This program is to see if you the user can guess the word!" %instructions 
put skip %skips a line 
put "The first word is always a capital letter!!" %instructions 
put skip %skips a line 
put "This word has : 5 letters!" %instructions 
put skip %skips a line 
put "Guess the letters for the 5 letter word!" % instructions 
loop %loop 
get guess %their guess 
s := 0 
for i : 1 .. length (word)% loops until they pick all the right letters 
if guess = word (i .. i) then %if they guess a certian letter 
put "You guessed letter # ", i, "!" %tells them that they guessed the certain letter 
s := 1 
end if %ends if 
end for %ends for 
if s = 0 then %if they didn't guess the letter 
put "You did not guess the letter!!" %if they didn't guess the letter it will say 
end if %ends the if 
end loop %ends the loop

-----------------------------------
Delos
Thu Jun 01, 2006 8:36 pm


-----------------------------------
Hello and welcome.

To start things off, please use 
if guess = word (i .. i) then

% Is equivalent to:

if guess = word (i) then

The variable 's' is not descriptively named.  Teachers are notorious for cracking down on this - and for good reason.  Badly named variables leads to confusion in their use, and hence buggy code.

When you get your programme working, may I suggest improving things a litte:
- create a list of possbile words to select, perhaps storing them in an array.  Use Rand.Int() to randomly select one of the words, and assign this to 'word'.  This will add more complexity and interactivity to your game.
- improve upon your interface.  The text if fine, but to make it look good, add some locates and colours.

-----------------------------------
XeroX
Fri Jun 02, 2006 7:32 pm


-----------------------------------
in order to keep track of the guesses, simply add to the value of an integer right after they enter their guess. you may want to limit their guesses, display a message such as "You have 5 guesses left" as well, it would be really cool if you actually made a hangman picture that got rid of a limb every time you don't get the correct letter
