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 / Just a little more hangman help?

Author
Message
MacMan
12
Years of Service
User Offline
Joined: 9th Apr 2012
Location:
Posted: 3rd May 2012 07:05
Almost done with my hangman game. Just have a few things left that I can not seem to figure out on my own.

1. No matter what I try I can't get the word that comes before guess in my game to go away without royally screwing everything else up.

2. I can't seem to figure out how to input Lower$ and Upper$ into my code in order for my game to accept upper and lower case letters as guesses.

3. I need to figure out an easy way to make it so when a duplicate letter is guessed it alerts the player and lets them guess again.

4. Lastly, I need my game to be able to access an outside word list in a .txt file. No clue on how to do this.

If you can lend a hand in any of this that would be super. Need to get this game finished up here soon. Thanks!

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 3rd May 2012 18:01 Edited at: 3rd May 2012 18:02
1. You are printing the answer just before you ask for input. See these lines:


All you need to do is REM out the command to print it as I have done.

2. Just convert the guess to lowercase (or upper case if you want) right after it is obtained. Like this:



3. You could create an array that has a size of 26. You would also need a pointer to the current spot in the array. You could then store the asci (see the ASC command) value of the entries as they are entered. Using the pointer, you check all entries up to that point to see if it has been entered previously.

4. Here is a simple example or loading strings from a file:





The file needs to exist in the same directory as your .dba file. I have attached the file, but really it is very simple to create using NotePad.

Your code could use some optimization. I am not a fan of using GOTO (please, other forum members, no goto fight is desired here) and your code could easily be restructured to eliminate it.

So many games to code.......so little time.

Attachments

Login to view attachments
MacMan
12
Years of Service
User Offline
Joined: 9th Apr 2012
Location:
Posted: 4th May 2012 05:59
I'm having some issues getting my game to open to my external wordlist properly. What am I doing wrong?

Attachments

Login to view attachments
MacMan
12
Years of Service
User Offline
Joined: 9th Apr 2012
Location:
Posted: 4th May 2012 06:00
wordlist is attatched to post.
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 4th May 2012 06:19 Edited at: 4th May 2012 06:25
Quote: "I'm having some issues getting my game to open to my external wordlist properly. What am I doing wrong?"


First off, is the "hangman.txt" file in the "hangmanfinal" folder? Is the "hangmanfinal" folder in the same folder as your .dba file?

I created the folders and placed your text file in there. It ran fine and told me I had ten words in the hangman.txt file and when I pressed a key it printed out the ten words.

Sounds like you are really close, you just need to get the folders set up correctly.

EDIT: It seems you have posted this on two different boards. You should not do that. It is likely one of them will get locked. From the AUP:
Quote: "
1) Please only post your question in one forum! People commonly post their question in both Dark Basic / Pro discussion and the Newcomers Corner. Please only post in one forum!
"


So many games to code.......so little time.

MacMan
12
Years of Service
User Offline
Joined: 9th Apr 2012
Location:
Posted: 4th May 2012 06:41
Yes the hangman.txt is in the hangmanfinal folder with the .dba file. When I try to run my program I get a runtime error for line 16 saying it can't open hangman.txt Do I have everything setup right?
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 4th May 2012 07:06
Insert this code:


in your program before you open / load the hangman.txt file. It will tell you whether or not it exists. If it doesn't, then you may have misspelled a filename or something else is wrong.

So many games to code.......so little time.

MacMan
12
Years of Service
User Offline
Joined: 9th Apr 2012
Location:
Posted: 4th May 2012 07:14
I inserted this code and ran it and it said the hangman.txt file does not exist. Hmm... but it definitely does. ???
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 4th May 2012 07:33 Edited at: 4th May 2012 07:35
Check your spelling very closely on the folder. The hangman.txt file works as downloaded.

EDIT: What is the name of your main program folder?

So many games to code.......so little time.

MacMan
12
Years of Service
User Offline
Joined: 9th Apr 2012
Location:
Posted: 4th May 2012 07:41
God what the hell its still saying it can't find the file and I've triple checked all spelling. Can I see exactly what you did to get it to work. Did you just copy and paste my code into a folder? Or what did you do exactly? Btw thanks for all the help I appreciate it much
MacMan
12
Years of Service
User Offline
Joined: 9th Apr 2012
Location:
Posted: 4th May 2012 07:44
I just have the hangmanfinal folder on my desktop and both the .txt and .dba files are in there.
MacMan
12
Years of Service
User Offline
Joined: 9th Apr 2012
Location:
Posted: 4th May 2012 09:10
I tried a different approach in getting my program to pull words from an external list and now I am getting a different error. I have both the .txt and .dba in a folder together named hangman. Can anyone see if they can get my program to work please. I have been having a hell of a time with this. Thanks guys! I've attached my wordlist with this post for everyone. Here is my updated code.

Attachments

Login to view attachments
Hodgey
15
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 4th May 2012 11:52
MacMan: I'm responding to your question in the other thread (about image coordintes) in this thread. I'm afraid I can't give you those coordintes because I did the rearraging in MS Paint, I didn't code it. However, simply open up the image in Paint (or any other image editor) and you should be able to see the pixel coordinates of the mouse on the image. I think you know where to go from there.

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 4th May 2012 16:48 Edited at: 4th May 2012 17:22
Quote: "I just have the hangmanfinal folder on my desktop and both the .txt and .dba files are in there."


That is the problem. The way you have coded it, the program is looking for a folder named 'hangmanfinal', but does not find it. The directory is set to 'hangmanfinal' already, by including it in the path, it is looking for another folder with that name.

So, instead of
just use


EDIT: Going through your most recent code, I had to do the following just to get it to compile. I have not gone through to see why it doesn't work right yet:

1. The itemletters array needed to be dimensioned (you had REMmed it out in line 59, I just unREMmed it)

2. You tried to define 'winner' as a string, but you had a function by that name already. I renamed the string variable to 'TheWinner' and changed the references to it.

3. The label 'start' does not exist at lines 164, 195 and 254. I think you meant the label, 'startofprogram'. The one at 254 does nothing anyway, so it should be deleted. Did I mention that generally speaking, GOTOs are a bad idea for structured programming?

4. Line 241 error - there is no function named 'endprogram()'. Why not just put the command, END for now? Also, this should be located after the user actually inputs a guess (i.e., move it to line 249).

POST EDIT:

Got it to work.
5. At lines 86 and 106, you listed gitem as gitem$

6. At line 124, you listed guess twice as guess$

So many games to code.......so little time.

MacMan
12
Years of Service
User Offline
Joined: 9th Apr 2012
Location:
Posted: 4th May 2012 18:27
Hey LBFN I went through and made all the of the changes that you suggested. And when I compile I get the error at line 101 cannot perform 'integer' cast on type 'TEMP3'. Don't know what this means. Also can I get rid of function Lose() and function Winner()?

Here is the updated code

LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 4th May 2012 19:08
Quote: "And when I compile I get the error at line 101 cannot perform 'integer' cast on type 'TEMP3'."

I told you what to do - see point #1 above.

Quote: "Also can I get rid of function Lose() and function Winner()?"

Sure, it's your program. If you eliminate them, how will you let the user know that they won or lost? You could simply rename the function instead of changing the string variable. It's up to you.

So many games to code.......so little time.

MacMan
12
Years of Service
User Offline
Joined: 9th Apr 2012
Location:
Posted: 4th May 2012 19:41
Yes!!! Got it to compile and run! Thanks for all of your help LBFN!
LBFN
17
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 4th May 2012 19:48
You're welcome

Glad you got it up and running. Good luck with it.

So many games to code.......so little time.

Login to post a reply

Server time is: 2024-11-21 23:37:28
Your offset time is: 2024-11-21 23:37:28