Here is the GUI:
[URL=http://img403.imageshack.us/my.php?image=guessawordjo5.jpg][IMG]http://img403.imageshack.us/img403/4409/guessawordjo5.th.jpg[/IMG][/URL]
I am making a program, same as hang man, a word guessing game.
This program is for the player to guess a word consists of 4 alphabets.
When the player guess correctly, a '0' will show in the list box with the correct position of the word.
When the player guess wrongly, a 'X' will show in the list box with the correct position of the word.
When the player guess correctly the word, a message will appear tellin the player the number of tries.
Loading
lau ren weiPosted Jun 27, 2008, 4:19 AM
ya!!! me too.. i am also doin a similar project exactly like yours. but i am stuck and am not sure how to do.... is there anyone who can help me out or any source code which is available??? please send it to [email protected] or add me at me hotmail address!!! :D
Mike SanPosted Jun 17, 2008, 12:50 PM
Nick NicholsPosted Jun 17, 2008, 4:30 AM
So you have a textbox TXT_INPUT that you get the entered text from by calling TXT_INPUT.Text on a button press, or by capturing the keydown event since all you want is a single character. Incrementsome sort of counter as well so you know how many guesses have been made and can then end the game or make high scores or something. Also would be useful in a generic "draw hangman" function which just looks at this integer and draws the figure appropriately. If it is 0, then draw everything, if 1 then draw all but leg A, if 2 then draw all but leg B and so on.
===========================
string myKnownWord = "c# corner";
List
int hangmanStage = 0;
bool isFound = false;
char[] myKnownWordArray = myKnownWord.ToLower().ToCharArray();
guessedCharacters.Add(TXT_INPUT.Text.ToLower().ToCharArray()[0]);
hangmanstage++;
string outputString = "";
for(int i = 0; i < myKnownWordArray.Length; i++)
{
if(guessedCharacters.Contains(myKnownWordArray[i]))
{
outputString += "0";
} else {
outputString += "X";
}
}
UpdateHangmanGraphics(hangmanstage);
return outputString;
====================
So the top are globals, the bottom is what you do when the user guesses. Take the string it returns and add it to the listbox...
You could make it a string where if guessed then add the actual character to the array, otherwise add an underscore or something like that to make it more hangman-esque.
Mike SanPosted Jun 15, 2008, 12:12 PM
lolz lolzPosted Jun 13, 2008, 8:42 PM
Mike SanPosted Jun 13, 2008, 12:38 PM
Thomas TafvanderPosted Jun 11, 2008, 2:15 PM
You have an example in classic asp here but it shouldent be any problem understanding the algorithm and translate it to C#...
http://www.asp101.com/Samples/hangman.asp
Best // TT
Mahesh ChandPosted Jun 11, 2008, 11:30 AM