Computer Science Canada Highscore table help. |
Author: | CapnChaos [ Thu Nov 18, 2010 8:56 pm ] | ||
Post subject: | Highscore table help. | ||
Hey guys, I'm new on here, and fairly new to using turing. I'm making a simple game where a computer player selects a random number, and then the human player tries to guess. I've got the game coded, and it works fine. However, I would like to create a high score table. Now, I know that I'll have to have it read and write from/to a text file, which I have created. Unfortunately, that's all i know about the topic. I've tried looking at other guides on here, but they don't really make sense to me, and I was hoping that somebody would show me how to do so. I have my code here, so if somebody could please tell me how to make a highscore table based on the code i have here it would be much appreciated.
<version 4.1.1> |
Author: | TokenHerbz [ Fri Nov 19, 2010 3:38 am ] | ||||
Post subject: | Re: Highscore table help. | ||||
to use a file in turing you must assign the file as a variable, thus letting turing know "which file" its to be using. You can refer to this as "streaming" from a file, to simplify things.
second to use this file, for a high score keeper, you'll have to use the "put" and "get" aspects of the I/O operations. to add to the file, we have to OPEN it using the value its assigned (streaming) and tell the PC to "put" the info we want, something like this.
so its simple to understand what that means. 1) We open the file (what file? Streaming file) at the location of the text we want to use. NOTE THE PUT, we use "put" to put in info, use "read" to get info, theres write/etc in there, F9 it, its all for something. 3) we tell it to "PUT" the info into the file, what info? Players scores. this can be ANY Variable really, boolean/reals,ints,strings. 4) we close the stream, it will auto close after your done with it, but its good practice to do anyways. To read your info is basically the exact same thing. Read from the file, and assign that info AS your HIGHSCORE, so you may use it on fresh programs. Enjoy! |