Sign in to follow this  
Side Winder

(C++) Doing Hi-Scores

Recommended Posts

Side Winder    174
So I currently have a scoring system where when a user does something, they get points. But I also want it so that when the user hits ESCAPE to quit, their score will be saved onto a file. Then when the game first initialises it'll read from the file and put the hi-scores (eg the top 10 scores) into a class/structure which can then be accessed by another function and be displayed in the window. How can I do this? I know the very basics of reading and writing from and to a file. Whenever I seem to write something to a file though, it won't save the input. Like I could write something to a file, but then when I re-run the program and do it again, it'll just overwrite what was already there... Thanks.

Share this post


Link to post
Share on other sites
JohnBolton    1372
It sounds like want you to do is to load all the high scores, add a new high score, and then overwrite the old list in the file with the new list.

Share this post


Link to post
Share on other sites
Side Winder    174
Pretty much, yep. I have an idea of how to do it now.

I'll write 10 "fake" names and scores in the initial file, read them in and then at the end of the game check whether the user managed to make a high score. If they do then overwrite one of the existing ones and then write back out again. Sound good?

Is there anyway for the user to input a string using the Win32 API btw?? I can think of only dialog(ue) boxes...

Share this post


Link to post
Share on other sites
Dialog(ue) boxes (well edit controls) are the easiest method unless you want to do your own input routine and GUI via WM_CHAR (or WM_KEYDOWN etc.) messages.

Yay! Someone else who knows how to spell dialogue!

"Dialogue box? I don't think so. A dialogue implies a 2-way conversation. All dialogue boxes have is an OK button. My wife has an OK button, it's called "Yes dear"

Share this post


Link to post
Share on other sites
Side Winder    174
Doing my own input routine could be interesting... Does mean a lot more work but I think I can handle it. Cheers.

And yes, I know how to spell! The amount of times I've used the English spelling for words while using C++ is quite astounding really...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this