Computer Science Canada Typing Game Help |
Author: | TerW [ Tue May 05, 2009 10:50 pm ] |
Post subject: | Typing Game Help |
Im trying to create a typing game. And i wanted a bunch of sentences on screen, and the user would have to input what is shown on the screen. Then the program will show how many mistakes the user made. The problem I am having is that im trying to find another way then making each word a variable. I have tried a procedure, but it verifies the whole sentence, instead of each individual word. |
Author: | Analysis Mode [ Tue May 05, 2009 10:51 pm ] |
Post subject: | Re: Typing Game Help |
ok why don't you post your code? And when parsing the input, look for spaces and punctuation as indicators that a word has ended. |
Author: | TerW [ Wed May 06, 2009 6:42 pm ] | ||
Post subject: | Re: Typing Game Help | ||
TerW @ Tue May 05, 2009 10:50 pm wrote: Im trying to create a typing game. And i wanted a bunch of sentences on screen, and the user would have to input what is shown on the screen. Then the program will show how many mistakes the user made. The problem I am having is that im trying to find another way then making each word a variable. I have tried a procedure, but it verifies the whole sentence, instead of each individual word.
|
Author: | tjmoore1993 [ Wed May 06, 2009 7:01 pm ] | ||
Post subject: | RE:Typing Game Help | ||
This should help you out with efficiency. However you should look at this guide... http://compsci.ca/v3/viewtopic.php?t=8229 |
Author: | Dusk Eagle [ Wed May 06, 2009 7:12 pm ] |
Post subject: | Re: Typing Game Help |
I hate to be blunt, but you're going to have to scrap 90% of that code and start over. Here is a MUCH better way to do it: Store a sentence inside of a text file. Use File I/O to read that sentence to a variable, with each word being a seperate element in a flexible array. For this example, let's call the array "words". Then, have a separate variable (just one!) to "get" the input from the user. Have a for loop that runs for the length of your sentence, and after each word checks if the input is equal to the word stored in "words" at that position. If this sounds complicated to you, it kind of is. But if you can implement at least some of this, it will make you a far better programmer. What you are doing is comparable to solving an arithmetic problem like 10^5 by grabbing a pencil and adding 10 + 10 + 10 + 10 + 10 ... Sure, you won't learn exponents overnight, but you might as well start now. You may not learn everything posted up there in a week (such as the flexible arrays - those can be tricky when you're starting), but ultimately you're going to have to strive to improve or go nowhere at all. Edit: I want to point out that you can always find plenty of Turing tutorials at http://compsci.ca/v3/viewtopic.php?t=8808. |
Author: | TerW [ Wed May 06, 2009 7:40 pm ] |
Post subject: | Re: Typing Game Help |
Thanks, Ill look into the tutorials and flexible arrays. I also want to know how i can incorporate a procedure into this program. Thank you. |
Author: | Dusk Eagle [ Wed May 06, 2009 7:59 pm ] | ||
Post subject: | Re: Typing Game Help | ||
There is, in fact. Here's a couple you could use:
Here's just some examples - see if you can come up with your own. |
Author: | TerW [ Wed May 06, 2009 9:07 pm ] |
Post subject: | Re: Typing Game Help |
Thanks, haha, its a little complicated for me, but I will try to comprehend this. Any other suggestions, or tips will be much appreciated. |
Author: | TerW [ Thu May 07, 2009 10:35 pm ] | ||
Post subject: | Re: Typing Game Help | ||
Hey, does this seem fine so far? Uh, I have a question as to how to put the words in certain postions, like starting a new sentence, or so a word would not get cut off?
|
Author: | Dusk Eagle [ Thu May 07, 2009 11:02 pm ] | ||
Post subject: | Re: Typing Game Help | ||
It looks pretty good when a couple things are fixed. Both the problems I can tell stem from this piece of your code:
First of all, why do you exit the for loop? That is like saying "If you type the word correctly, you have to start over." The other issue is that you only display the word the user needs to type in only after they have typed in said word. I can see what you were getting at; you meant to put "text(i+1)", but even that won't work because your for loop will continue on whether or not the user enters in the correct word. So why not just display the word above your "get" line, thus avoiding this problem? I can't answer your main question because I don't understand it, but my suggestions above should help your code anyway. |
Author: | TerW [ Fri May 08, 2009 6:14 pm ] |
Post subject: | RE:Typing Game Help |
Alright, sorry for not stating the question more clearly. My question is asking how I can control the position of words on the screen. For example; when i get the words from the file, and i put them on screen they appear without any spaces in between the lines like this: "The words all appear, but there are no spaces into between each line, even if the text file does have spaces. I want to have spaces between the lines because that is the space I wanted to user to type in." I would prefer something like this: "All I want are spaces between each line, so there is a space for the user to input and type in the words that appear on the screen." I have tried using "locate" but I have difficulty using it in a loop changing the row every certain number of words. |