Computer Science Canada Highscores List |
Author: | TFish [ Sat Feb 18, 2012 9:13 pm ] | ||||||||||
Post subject: | Highscores List | ||||||||||
This is a highscore procedure that I've used in a few games I've made, but I thought I'd post it here in case someone doesn't know how to do it. Here is the entire code:
This opens up the highscores.txt file (where the scores are kept), and it saves every line into a variable. The first line is the name, and is saved into hNames (i), the second line is the number, and is saved into hScores (i) and the space is saved into the space variable. This is repeated for however many scores there are. At the end, it closes the file
This part checks where the current score (the one the player just got), and finds out where it fits in the list (if at all). You want to start from the bottom, because your list should already be highest at the top and lowest at the bottom. If the current score is higher than the one saved, then you have to move all of the scores down, and save the current score in the spot where it fits (e.g., if the current score is higher than the 4th, but lower than the 3rd, the current score will be saved in the 4th position, the 4th place score will be saved in the 5th position and the 5th place score will be knocked off the leaderboards).
This will now save the revised score in the highscores.txt file.
This is the format the highscores.txt file has to be in. Remember to have an extra space at the end of the file.
If you have any improvements, feel free to post them. |
Author: | TW iz Rippin [ Thu Feb 23, 2012 11:57 am ] |
Post subject: | RE:Highscores List |
+bits ty |
Author: | Flying Carpet [ Wed Jun 13, 2012 9:02 pm ] |
Post subject: | RE:Highscores List |
Well it is obvious that the User var that you use has to bewhatever your "user" var is, but, when I create a new var "user" or whatever I want and change the code accordingly I get an error. Turing tells me "user cannot be followed by a "." Any help? |
Author: | Tony [ Wed Jun 13, 2012 9:52 pm ] |
Post subject: | RE:Highscores List |
what's the type of the user variable that you created? |
Author: | Flying Carpet [ Thu Jun 14, 2012 5:58 pm ] |
Post subject: | RE:Highscores List |
Well its a char1 variable, implying to player 1, which has an assigned sprite. This is a game for a Grade 10 Final project, with a partner, still a work in progress. What I don't get is why use such a long code. I saw a tut that has maybe 5-10 lines for highscores. Another problem is we cant figure out for the hell of us how to pause the game, even our teacher doesn't know lol. The game itself is a procedure. While using the pause command, you set time "UNITS" Even if this is set to 1, the pause goes on forever. Why? Also the Input.Pause wont work either. What we want is an interactive pause screen to pop up once a certain key is pressed, and to unpause when the SAME key is pressed. |
Author: | Tony [ Thu Jun 14, 2012 7:07 pm ] |
Post subject: | RE:Highscores List |
Turing is right. Char1 type does not contain any properties/methods, so using the .-operator is meaningless. It would be best for you to simply implement your own code -- easier to understand too. |
Author: | Flying Carpet [ Thu Jun 14, 2012 7:13 pm ] |
Post subject: | RE:Highscores List |
About the pause why is that? I tried the Input.Keydown, then an Input.Pause. If you press P it pauses, and waits for a keystroke, and will unpause when any key is pressed, how can I make it so it only unpauses after the P key is pressed again? Also, while it is in Input.Pause, there is an annoying screen flash in a corner (waiting for input), I tried noecho and it still flashes. |
Author: | Tony [ Thu Jun 14, 2012 7:59 pm ] |
Post subject: | RE:Highscores List |
you should probably read what input_pause actually does. |
Author: | Flying Carpet [ Thu Jun 14, 2012 10:47 pm ] |
Post subject: | RE:Highscores List |
Thanks for all the info Tony, but yes, I tried noecho before and it still happened. |