Does anyone have any cunning plans for how I could make a basic single player hangman game in VB? I would like to be able to draw random words from a text file for it.
Cunning? Don't know about that. Your program presents three problems (easy to solve).
First: Graphics...drawing a man can be done using the LINE control and the SHAPE control. Place them on a form the way you want the 'stickman' to look. Once designed set the ENABLED property of each of these to false so they will not be seen on the form. To test, add Command button so when it is clicked one body part at a time is enabled. You may use a variable that has an initial value of 0. Increment this with button click. Use SELECT CASE to decide what body part to enable as the value increases.
Second: Loading word. Build text file with some sample words. Write routine to read this file (add Random load after program is working) Search the forum for the 'how to...?' I am sure this has been answered before. As the form loads, have a word automatically read from file and loaded into variable.
Third: As a person enters a letter, use the INSTR command to see if the letter is in there. If so, create a new variable with those letters...using spaces for letters not yet solved. MID( ) will work well here. Each incorrect guess enables another body part to be added.
Hi,
I went ahead and wrote this little Hangman program tonight that has over 60 VB specific words/properties/functions in a word file. I will modify it for my children. It is compact and looks pretty neat.
I have provided error handling for the file load operation. Have fun. There is a really cool bug. Take a look and let me know how you fix it.
192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
Posts
3,051
ChuckB, is the error the fast drawing of the man, when holding down? If so, you could just have a button to click, for guessing a letter, then run the check code in the click event, instead of in the listbox change event.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe "I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons