Alright now that we have those in place, how do we replace them with a correctly guessed letter?
Ex:
Paper..
_ _ _ _ _

they guess a P

P _ p _ _
actually i got it all figured out for now i think.. but what does this do? how does it work?
Code:

Code:

:"-


I noticed that if I take this part out, it displays abcdefghijklmnopqrstuvw..
but with it added in it displays the number of -'s according to the length of your word.. i don't get this Razz
Please don't double post. There is an edit button above each of your posts, use that please.

Responded to your "I don't get this", the reason is because the string "abcdefgh..." is in answer before you run that routine. Putting that string into answer (the "-" one) makes it use that to duplicate to show how many lowercase letters. After your program displays the "abcdefg..." add in a
Code:
Pause Ans
and check what Answer is (scroll through it). It should be something along the lines of: "abcdefgh...wxyzabcdefgh...wxyz".
To elaborate a bit, Ans (Answer) is a special variable maintained by the parser. Every time you do a store (like 3->X or "HELLO->Str1) that value is also dropped into Ans. So if you did:


Code:
"HELLO->Str1
:Disp Ans


You would see hello. Store 3->X instead, and you would see 3. The trick that I used is implicitly storing to Ans without actually storing anywhere else. I could have written "- ->Ans, but that's redundant.
Oh! so..
:A, This is storing A to ans?
KermMartian wrote:
To elaborate a bit, Ans (Answer) is a special variable maintained by the parser. Every time you do a store (like 3->X or "HELLO->Str1) that value is also dropped into Ans. So if you did:


Code:
"HELLO->Str1
:Disp Ans


You would see hello. Store 3->X instead, and you would see 3. The trick that I used is implicitly storing to Ans without actually storing anywhere else. I could have written "- ->Ans, but that's redundant.

I think ->Ans is actually an illegal operation Razz
joshie75 wrote:
Oh! so..
:A, This is storing A to ans?
Exactly. And calc84, I guess I never had occasion to try until you just mentioned that; it is indeed a Syntax error.
Man you guys help out a lot, I'm starting to feel bad Sad lol.
Kerm, I innovated your "Already guessed" operation and i have two slight problems... 1 with the innovation and another with the play again screen :S
1) It still adds a body part, even the the letter was already guessed.
2) The play again screen: It doesn't follow the Key pressed... I have WINDOW set as yes and TRACE set to no... I pushed WINDOW and it went to the window adjust screen instead of going to the Lbl.
Here is my Updated Code..

Code:

Code:

:Lbl 5
:0->W
:0->G
:0->R
:"ABCDEFGHIJKLMNOPQRSTUVWXYZ"->Str3
:ClrHome
:ClrDraw
:AxesOff
:Input "Your word please",Str1
:Text(1,1,"Number of letters"
:"-
:For(L,2,length(Str1
:Ans+"-
:End
:Text(8,1,Ans
:Pause
:Lbl 1
:ClrHome
:Input "pick one letter ",Str2
:Repeat Z=0
:inString(Str3,Str2)->H
:inString(Str1,Str2,N)->Z
:inString(Str1,Str2)->F
:If F=0
:Goto 2
:If Z>0
:R+1->R
:Lbl 3
:If W=6
:Goto 4
:Text(16,1,"Number of letters in word"
:Text(24,1,R
:Z+1->N
:inString(Str3,Str2)->I
:If I=0
:Goto 6
:"/"+Str3+"/"->Str3
:sub(Str3,2,H)+"/"+sub(Str3,H+2,27-H->Str3
:sub(Str3,2,26)->Str3
:0->R
:1->N
:1->Z
:Text(40,40,sub(Str3,1,13
:Text(50,40,sub(Str3,14,13
:Line(-8,-9,-3,-9
:Line(-4,-9,-4,0
:Line(-4,0,-7,0
:Line(-7,0,-7,-2
:Pause
:Goto 1
:Lbl 2
:W+1->W
:If W=1
:Circle(-7,-3,1
:If W=2
:Line(-7,-4,-7,-7
:If W=3
:Line(-7,-7,-7.5,-8
:If W=4
:Line(-7,-7,-6.5,-8
:If W=5
:Line(-7,-5,-7.5,-6
:If W=6
:Line(-7,-5,-6.5,-6
:End
:Pause
:Goto 3
:Lbl 4
:ClrHome
:ClrDraw
:Circle(0,0,4
:Text(5,25,"You have lost"
:Text(26,40,"X
:Text(26,52,"X
:Text(45,28,"Play again?"
:Text(53,16,"Yes"
:Text(53,70,"No"
:Line(0,-1,-1,-2
:Line(0,-1,1,-2
:Getkey->K
:While K=0
:If K=12
:Then
:Goto 5
:If K=14
:Then
:Goto 7
:End
:Lbl 6
:ClrHome
:Output(3,5,"Already
:Output(5,5,"Guessed!
:Pause
:Goto 1
:Lbl 7
:Output(3,5,"Made by"
:Output(5,2,"Josh Beckwith"
Well, I don't see any getKeys to catch TRACE and GRAPH. The following code bothers me a lot:


Code:
:Getkey->K
:While K=0
:If K=12
:Then
:Goto 5
:If K=14
:Then
:Goto 7
:End
Let's try this instead, which (1) removes the brokenness and (2) removes the memory leakage:


Code:
:Repeat K=12 or K=14
:getKey->K:End
:If K=12:Goto 5
:Goto 7 //otherwise, K must be 14//
Hmm, this is all starting to make sense Smile
Now what can we do about it still adding a body part for guessing the same letter?
I've tried adding a variable to the end of each line and if the letter was already guessed it would store the variable as a 0, meaning the line would be white, but no luck. Sad
joshie75 wrote:
Hmm, this is all starting to make sense Smile
Now what can we do about it still adding a body part for guessing the same letter?
I've tried adding a variable to the end of each line and if the letter was already guessed it would store the variable as a 0, meaning the line would be white, but no luck. Sad
I'm not sure precisely what you're saying there. Adding a body part for guessing the same letter?
Well what it does so far... is even if you re-guess a letter on accident, it acts like you guess a wrong letter and still adds a body part to the "Hangman" Razz
Like say you guess K and its wrong.. It will add the Head and cross K off. Then if you guess K again it will add the body. How do i make it so it doesn't add on that extra body part for every time you re-guess a letter?
joshie75 wrote:
Well what it does so far... is even if you re-guess a letter on accident, it acts like you guess a wrong letter and still adds a body part to the "Hangman" :P
Like say you guess K and its wrong.. It will add the Head and cross K off. Then if you guess K again it will add the body. How do i make it so it doesn't add on that extra body part for every time you re-guess a letter?
You'd have to have it remember each letter that's been guessed so far by some means, then when you input a letter, have it check to be sure that letter hasn't been guessed already before it does anything else. Or you could just say, "You were stupid enough to guess that letter again, you deserve to have [such and such body part] added to the hangman!" But that's the easy route which won't help you with learning to program.
Well, if you were using that alphabet -> "/" replacement code we were using, you could use inString(that alphabet, letter guessed) to determine if the letter had previously been guessed...
KermMartian wrote:
Well, if you were using that alphabet -> "/" replacement code we were using, you could use inString(that alphabet, letter guessed) to determine if the letter had previously been guessed...
Then if a letter didn't show up, it means that you've already guessed it because the letter has already been replaced?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 4 of 4
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement