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 / TDK help with hangman!!

Author
Message
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 11th Oct 2005 06:39 Edited at: 11th Oct 2005 06:41
USING DARKBASIC PROFESSIONAL
@TDK, I found a crude hangman do...loop that you posted somewhere around here and I saw an opportunity to try out arrays. I was wondering if you can help me out with this; tell me if I'm going in the right direction or not. Also, I found that, in it's original form (with Alphabet$=the alphabet) after the 11th letter that you guess, the program will no longer print the rest of the Alphabet$.
What I want the program to do is let you choose a category (1=insets,2=names,3=colors) and it will randomly select one of the 5 words in the category that you choose. You will be allowed 8 incorrect answers until the word is revealed and the game is over.

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Oct 2005 07:39
Quote: "For N=1 To Len(Category$)"


Category$ isn't a string variable, it's an array. It should be:

For N=1 To Len(Category$,N)

Quote: "
`not sure why I declares these next two things, but I think I need to
`this is for the categories
for c=1 to 3
`this is for the word
for w=1 to 5
"


You don't need this section at all. Use this at the start of your program:



You would then use 'Catnum' as the first index of the array and pick a random word:



Quote: "Alphabet$ = Left$(Category$,N-1)+Right$(Category$,Len(Category$)-N)"


The idea of the alphabet string is that when a letter is guessed, you remove it from the alphabet string. That way, the letter is not there the next time the same letter is entered and you can say "Already used that letter!"

So, if the letter B is chosen, alphabet$ changes from:

ABCDEFGHIJKLMNOPQRSTUVWXYZ

to

ACDEFGHIJKLMNOPQRSTUVWXYZ

and you can quickly check to see if B (or any other letter) has been used before because if it has, it will not be present in alphabet$.

TDK_Man

RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 11th Oct 2005 14:39 Edited at: 11th Oct 2005 14:40
Lol TDK, your name has become a norm in todays posts


TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 11th Oct 2005 16:20
Only because I wrote the snippet Krimzon DestinE is having problems with. That's all.

My code tends to work, but can be quite strange at times and difficult to follow for beginners.

TDK_Man

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 12th Oct 2005 18:55
Lol, but seriously, everywhere you look you can atleast see 'TDK' once! I wish I was that popular


Darkbasic MADPSP
19
Years of Service
User Offline
Joined: 15th Jun 2005
Location: Uk
Posted: 12th Oct 2005 19:01
me too

Platformer soon to be wip you'll like it
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 12th Oct 2005 19:25
Just hit the books guys. TDK is popular because he knows his code. If you keep learning, using what you've learned, and help others with their problems you too will be as popular as TDK.

Strive to be #1!
Darkbasic MADPSP
19
Years of Service
User Offline
Joined: 15th Jun 2005
Location: Uk
Posted: 12th Oct 2005 19:39
Thanks for the encouragement mate

Platformer soon to be wip you'll like it
Deep Thought 42
19
Years of Service
User Offline
Joined: 31st Jul 2005
Location: New Jersey, USA
Posted: 12th Oct 2005 22:34 Edited at: 12th Oct 2005 22:35
@Grog Gruelsalyer & Darkbasic MAD
I wouldn't expect to be like TDK for a while. He's been with this for over three years. While you guys just joined this year (like me!). But I guess if I practice a lot I could be almost as helpful as TDK. It also helps not to flame noobs to death.

"There are no stupid questions, just a lot of inquisitive idiots."
RUCCUS
19
Years of Service
User Offline
Joined: 11th Dec 2004
Location: Canada
Posted: 12th Oct 2005 23:17
It shouldnt really be about popularity Im sure TDK isnt helping people so much to be popular.


Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 13th Oct 2005 00:44
TDK is the shiz-nik!!! He knows what he's talking about and he doesn't bash noobies for not knowing.He doesn't act as if he knew it all his life like many others do.
Xenocythe
19
Years of Service
User Offline
Joined: 26th May 2005
Location: You Essay.
Posted: 13th Oct 2005 00:48
You mean like me? Well of course he is! Everyone wants to be!

Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 13th Oct 2005 02:46 Edited at: 13th Oct 2005 03:13
I want the screen to display the current number of unknown spaces instead of showing the actual spaces. After the user guesses a correct answer, the current number of unkonwn spaces will decrease by however many letters his guess occupies of the CurrentWord$.
For example, if the CurrentWord$ is Yellow then the screen will display "Number of available space: 6". If the user guesses 'l', the the screen will display "Number of available space: 4".

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 13th Oct 2005 06:08
I can't remember now, where that code was posted. Can you remember?

It's a while since I did that snippet, so it's difficult to remember what I did.

CurrentWord$ is the full word. Is there another variable which is used to hold what the word is for displaying the word so far guessed by the player?

If not, then when you set CurrentWord$, create another string called GuessWord$ or similar to be the same length, but made up from asterisks with:



After this, if CurrentWord$ was 'BANANA' then GuessWord$ would be '******' (same number of letters).

Every time the player guesses a correct letter, you replace one (or more) asterisks in GuessWord$ with that letter. So if the user guesses the letter N, then GuessWord$ becomes '**N*N*'.

Then a simple For..Next loop allows you to check for what you need:



This would tell you in our banana example that there were 4 spaces - the number of missing letters, but doesn't take into account that the four missing letters are not unique.

TDK_Man

Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 13th Oct 2005 07:07
Quote: "I wouldn't expect to be like TDK for a while. He's been with this for over three years. While you guys just joined this year (like me!). But I guess if I practice a lot I could be almost as helpful as TDK. It also helps not to flame noobs to death."


Back in the 80's I was programming in Basic/GWBasic and in the 90's Quickbasic. I'm pretty sure that TDK has also programmed long before Darkbasic was made. Those of us that have programmed in any of the old Basic languages have an easier time with Darkbasic but it's still the same thing... if we don't practice, practice, practice we'll never come close to TDK.

To me TDK is cool because he knows his code... and he's not a snob about it. He does get upset if any newbie uses "goto"... and I support him 100%! Goto is dead! Long live functions! I personally don't like to use "gosub" either.

TDK is SO modest too... notice how he didn't say anything about our fan club... he just kept helping Krimzon DestinE.
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 13th Oct 2005 23:52
Quote: "notice how he didn't say anything about our fan club"


what fan club?

@TDK I can't begin to declare how greatful I am to you. So, I will just say thanks.
Krimzon DestinE
19
Years of Service
User Offline
Joined: 18th Sep 2005
Location:
Posted: 14th Oct 2005 00:31


So how's it lookin?

Login to post a reply

Server time is: 2024-11-27 16:31:42
Your offset time is: 2024-11-27 16:31:42