Computer Science Canada Need some help to improve my game in turing |
Author: | Anastasia [ Sun May 22, 2011 4:33 pm ] | ||
Post subject: | Need some help to improve my game in turing | ||
Hi guys! I'm trying to make a game in turing based on Zork game. ( But much simpler) Have some problems though...don't know how to get rid of them... like in the part where it says "You're facing the east of the house. There is a cracked window. If you want to open and enter the window enter 'in'" and when I enter 'in' first time the program says "I don't understand" and when I enter it second time the program says what I want for it to say the first time. PLEASE HELP..... [b]SORRY FOR ANY GRAMMAR MISTAKES....ENGLISH IS NOT MY FIRST LANGUAGE Here is what I've got so far.....
It is not finished.... Also, I would appreciate any suggestions on how to improve my game. Thanks in advance... ![]() |
Author: | Tony [ Sun May 22, 2011 4:48 pm ] |
Post subject: | Re: Need some help to improve my game in turing |
Anastasia @ Sun May 22, 2011 4:33 pm wrote: and when I enter it second time the program says what I want for it to say the first time.
You are handling first and second inputs with different get statements; so your second answer is for a different part of the code, so it's handled differently. |
Author: | Zren [ Sun May 22, 2011 4:49 pm ] |
Post subject: | RE:Need some help to improve my game in turing |
Open up a new program and type break. Run that program. The editor will now enter a sort of debuging mode. Checkmark trace execution. Go back to your origional application and run it. Watch how the logic runs. To exit the debuging mode, you have to close and reopen Turing. That should hint at your error. Hint: - You need a variable to distinguish where you are. |
Author: | Anastasia [ Tue May 24, 2011 10:28 am ] |
Post subject: | RE:Need some help to improve my game in turing |
To Zren: ok I did what you said.... still don't understand how change it..... I don't really understand what you mean by "You need a variable to distinguish where you are." |
Author: | Tony [ Tue May 24, 2011 10:50 am ] | ||||
Post subject: | Re: RE:Need some help to improve my game in turing | ||||
Anastasia @ Tue May 24, 2011 10:28 am wrote: I don't really understand what you mean by
"You need a variable to distinguish where you are." Right now that information is encoded in the structure of your if-statements (and you leave comments for yourself). You could also track that location (where the character is) in a variable, which makes some things much easier to do. E.g.
Not as a part of the final game, but just for the development process. A common approach are flags to turn this information on/off
This gives you two pieces of information: 1. What state you've set your character in. 2. What line of code is executing at the time. |
Author: | Anastasia [ Tue May 24, 2011 5:36 pm ] |
Post subject: | RE:Need some help to improve my game in turing |
OK that makes sense Thanks! |
Author: | Anastasia [ Tue May 24, 2011 5:44 pm ] | ||
Post subject: | Re: Need some help to improve my game in turing | ||
I have a question..... if want to use an "exit when" statement can I wright it like that?
|
Author: | Zren [ Tue May 24, 2011 5:51 pm ] | ||
Post subject: | RE:Need some help to improve my game in turing | ||
Infinite loop. You never exit because you're contradicting yourself. When a3 is not "go" then you enter the else statement. Then you exit if it does equal "go", which isn't possible since you already filtered out that it isn't "go". An exit when is pretty much a combined if statement + exit.
|
Author: | Anastasia [ Tue May 24, 2011 6:00 pm ] | ||
Post subject: | RE:Need some help to improve my game in turing | ||
ok but what if i need to have statement that says: " there are 2 doors" and then exit? like in my example should I put exit when at the end or like that:
where exit when follows the 'put' statement? |
Author: | Zren [ Tue May 24, 2011 6:03 pm ] | ||
Post subject: | RE:Need some help to improve my game in turing | ||
That's correct. Just going to point out again, don't need to check if it's "go" again, as you already know that when you entered the if statement. Using just exit works the same.
|
Author: | Anastasia [ Tue May 24, 2011 6:06 pm ] |
Post subject: | RE:Need some help to improve my game in turing |
oh OK... I got it now thanks so much! ![]() |