Archived

This topic is now archived and is closed to further replies.

GoomfGoomfDweeda

Help with my hiscore-list

Recommended Posts

Hi all! I''m working on my Tetrisclone called Blocky, written i C on Win32-platform with DirectX blablabla.... I would like a hiscorelist that loads from a file, and saves to a file when the hiscores are updated. I have browsed through the forums and found some help. But I''m stuck here and I like to tell you what I know, and perhaps somebody can help me with the things that I don''t know... Ok. Here''s what we''ve got: 1. I want to load my file Hiscore.dat in the beginning of the game and process this file so that the data is in right places (I''m currently using an array of ten struct''s that holds the player''s name and the score and the level for the actual player) i.e. PlayerData[10].name, PlayerData[10].score and so on... Some problems here, but I''ll think I''ll work it out though... 2. First I play the game until I die (the pieces doesn''t fit) and my score and level is recorded in my variables. Secondly, I want to compare my score with the scores loaded from the file. This is where my trouble begins.... Can you help me with some tips and advice how to do this efficiently? I have ten positions in my hiscore-list, all of them with playername, score and level of the player. When my score are higher than one of the scores in the file, I''ll want to take its place and push those with lower score below mine... (Hehehe. Sorry, of course you know what I mean!) And delete the person who is on the last place so that the list never exceeds 10 positions. 3. My newly updated hiscorelist are saved to file again. Well, I''m sure I can work this out... 4. Show my hiscore on the screen. No problems if I just could manage the other things. As you can see, I know in theory how this will work, but I''m lacking in the skills to make it happen. I have no sample code to provide because I have tried a lot of possible ways, but I just can''t figure it out. I have a whole bunch of projects, but I don''t see the point to post any of them here. Just consider that I have tried a lot, but ended up with nothing but headache :-) Any advice are welcome. It seems that I just need some direction or another point of view to my problem. I would kindly accept all possible solution. Thank''s in advance! GoomfGoomfDweeda (Well, what can I say ? All other cool names are busy!) You have to be who you are, when you didn''''t become what you should...

Share this post


Link to post
Share on other sites
Neodraco    122
Seems like you don''t have very much programming experience. Since I don''t have much time I will try to explain the hi-score comparison thing.

The best you can do is store the scores ordered in the array, from the lesser to the greater. Then, when you have a new score, you have to scan the array with a for or a while statement, comparing the hi-scores with the scores that you have. If the first hi-score is greater than yours, then there''s no new high score. If not, you continue until you find a high score greater than yours. If there''s none, your score is the first. In either case, you delete the last hi-score and copy the next score in the slot you just have deleted, until the position of your new high score.

Ok, I know it will be pretty much understandable with a little code sample, tell me if you can''t guess how it works.

Oh my god, I need 2 hours a day more!

Share this post


Link to post
Share on other sites
Thanks for your time Neodraco!
I think I will solve this problem now. At least I know now that my approach to the problem is a possible way to work it out. It will work that way, and that is the most important to know for now. I''ll try to do it now, and if I get stuck and have nowhere else to go, I''ll post here again. In the meantime: if anyone have other suggestions you are more than welcome to reply!
Thank''s again!



GoomfGoomfDweeda (Well, what can I say ? All other cool names are busy!)

You have to be who you are, when you didn''t become what you should...

Share this post


Link to post
Share on other sites
Thanks for your time Neodraco!
I think I will solve this problem now. At least I know now that my approach to the problem is a possible way to work it out. It will work that way, and that is the most important to know for now. I''ll try to do it now, and if I get stuck and have nowhere else to go, I''ll post here again. In the meantime: if anyone have other suggestions you are more than welcome to reply!
Thank''s again!



GoomfGoomfDweeda (Well, what can I say ? All other cool names are busy!)

You have to be who you are, when you didn''t become what you should...

Share this post


Link to post
Share on other sites