Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / hangman game help plz

Author
Message
Milky the purple crab
19
Years of Service
User Offline
Joined: 5th Aug 2005
Location:
Posted: 10th Aug 2005 11:56
hey, can someone tell me how to make a hangman game with DB please?
i heard it is a good place to start. I don't know how to make it.

I don't fear pain.....I fear feeling it.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 10th Aug 2005 23:10 Edited at: 10th Aug 2005 23:27
An outline:

Start with using a single word:

A$="Butterfly" for example. You can add further words later.

Create another string called Attempts$ and put the alphabet into it:

Attempts$="ABCDEFGHIJKLMNOPQRSTUVWXYZ"

In the program's main loop, use Input to prompt for and accept the users choice of letter.

Check to see if that letter is in Attempts$. If it is, remove it (check out Left$, Mid$ and Right$). If it isn't then that letter has been chosen before so do nothing.

Check to see if the letter is in the current word and if it is, update the screen.

If the letter isn't in the current word, remove the letter from the alphabet string and add to the hangman graphics. Add one to the number of goes used.

And so on...

If the hangman graphic is made up of say 12 sections then when your variable holding the number of goes reaches 12 then the player has run out of goes and the game ends.

That should be something to be going on with...

TDK_Man
Cameron
19
Years of Service
User Offline
Joined: 7th Aug 2005
Location: In Your Closet...
Posted: 11th Aug 2005 00:21
Or i think you may be able to use case statements. correct me if im wrong but i think u can


My Current Project: InvaDerz!
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Aug 2005 03:49 Edited at: 11th Aug 2005 03:51
Where?

I think you are assuming that you would have to have a load of If..Then statements - which isn't true!

Instead of

If Guess$="A"
If Guess$="B"
If Guess$="C"

and so on, you would use strings like this:



When you run it, enter a letter and it is removed from the alphabet string. The next time you enter the same letter, it isn't in the alphabet string so you get the message that you've already entered that letter.

This is a simple but common method for this sort of thing and can also be used to deal cards from a pack in card games. Simply fill the string with all the cards and deal them randomly - removing them from the string as they are dealt so they can't be dealt again.

You might think that strings aren't a lot of use for 3D games, but you'd be surprised.

It's well worth taking the time to play with strings until my example code makes sense to you.

Any questions - just ask!

TDK_Man
Cameron
19
Years of Service
User Offline
Joined: 7th Aug 2005
Location: In Your Closet...
Posted: 11th Aug 2005 06:19
Oh ok i see


My Current Project: Tic Tac Toe
Milky the purple crab
19
Years of Service
User Offline
Joined: 5th Aug 2005
Location:
Posted: 11th Aug 2005 07:45
thx tdk_man.

DB's easier than most but still hard as a newbie, are their any tutorials that i can download?

I don't fear pain.....I fear feeling it.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Aug 2005 18:05
Check out the posts at the top of the Newcomers forum (the ones with green arrows on them).

TDK_Man

Login to post a reply

Server time is: 2024-09-24 01:34:43
Your offset time is: 2024-09-24 01:34:43