Reply

Join Date: May 2009
Posts: 1
Reputation: Sniper87 is an unknown quantity at this point 
Solved Threads: 0
Sniper87 Sniper87 is offline Offline
Newbie Poster

Hangman Game

 
0
  #1
May 14th, 2009
Hey guys first post here.

Down to business, i have to create a hangman game in VB5 for a Yr 12 assignment. So far i have created a help screen and a word list and a main menu list to navigate to these forms, however i am struggling with the main game section.

So far all i have mangaed to come up with is a flow chart of what i want the program to do:

1. Form loads the wordlist

2. Picks a random word from the wordlist and display it as dashes in a label called "lblWord"

3. Keyboard on Screen enabled (I have an on screen keyboard made of command buttons they also do not work)

4. Everytime a letter button is pressed the game needs to check through the word and if the letter is not in the word load the next image of the hangman picture and decrease the counter by one (counter counts down the amount of incorrect guesses remaining) If the letter is in the word the dash in the word needs to be replaced with the letter.

5. The letter on the on-screen keyboard is disabled

6. If the word is complete user as won

7. If te hangman counter reaches zero the user has lost

This is what i have so far regarding the actual game, i also need help with making the letters work on the on screen keyboard.

Thanks fo any/all help you can give me

Sniper87
Last edited by Sniper87; May 14th, 2009 at 11:50 pm.
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 807
Reputation: vb5prgrmr will become famous soon enough vb5prgrmr will become famous soon enough 
Solved Threads: 147
vb5prgrmr vb5prgrmr is offline Offline
Practically a Posting Shark

Re: Hangman Game

 
0
  #2
May 15th, 2009
Well since you have command buttons on the form you cannot use the form's keypreview property but you can use any of the following events of the command buttons as long as they have the focus...

KeyDown, KeyPress, KeyUp

Now, as for checking if the letter is within the word/phrase you can use the Instr function (see vb's help(*)). To replace the dash with the letter the user guessed you can use the mid function(*). Also, when the user has a word like "Remember" and they guess the "e" you will need to check for each "e" in a loop when using instr.


As for incorrect guesses you will need a form level variable and as each new game starts you will have to reset it there. Then as each incorrect guess is made you will have to decrement the value of the variable prior to displaying its value and prior to testing it for equaling zero (0).

Good Luck
If anyone has helped you solve your problem, please mark your thread as solved.

Thanks
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 23
Reputation: JohnKelly is an unknown quantity at this point 
Solved Threads: 0
JohnKelly JohnKelly is offline Offline
Newbie Poster

Re: Hangman Game

 
0
  #3
May 15th, 2009
I presume the Command buttons on the screen are linked to letters of the alpabet. If you set up these buttons with the same name so they are indexed it is fairly simple to linke the index of the command button to the letter e.g. Command(0)=A Command(1) =B etc etc

When a button is pressed you can determine the letter as the index will relate to the Ascii number. Command(0) = Ascii 65 = A, Command(1) = 66 = B and so on.

once you know what the letter is you can then loop through your "word" to see if it is present. If it is you replace your dash with the letter.

If it isn't then increment the miss counter by one and load the correct picture. You can do this with a

Select MissCount
case 1: Picture1.load Image1
case 2: Picture1.load Image2
etc etc
end select

Hope this helps ... good luck
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 372
Reputation: Jupiter 2 is an unknown quantity at this point 
Solved Threads: 26
Jupiter 2 Jupiter 2 is offline Offline
Posting Whiz

Re: Hangman Game

 
0
  #4
May 23rd, 2009
www.geocities.com\excelmarksway
Select Games > Hangman.xls
Save the file.
Open Excel then open Hangman.xls
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC