High Scores in Cocoa
Just a quick question about good programming practice with reguards to Cocoa.
Is it acceptable to store the high score information for my game in the User Defaults using the NSUserDefaults functions or is it better to store the information in a seperate file?
Thanks,
Is it acceptable to store the high score information for my game in the User Defaults using the NSUserDefaults functions or is it better to store the information in a seperate file?
Thanks,
I've tried it both ways, and I think its best in some user defaults
GoodDoug,
Thanks for that - it reassures me that I'm not starting to use bad practice.
Thinking about it though, if I do the user defaults method, will there be seperate high scores for each user who logs into the computer or will it be shared across all the users?
Thanks for that - it reassures me that I'm not starting to use bad practice.
Thinking about it though, if I do the user defaults method, will there be seperate high scores for each user who logs into the computer or will it be shared across all the users?
There would be a different high score for each user.
Is there a shared equivalent of user defaults? Or am I maybe being a bit fussy for a game high score table?
Not that I know of and looking through the NSUserDefaults docs, there doesn't appear to be one. Perhaps you could save the user name of whoever lauches it first, and then use -initWithUser to load that prefs file. Of course that seems like a lot of trouble for something so trivial that you could just store in a plist in your app's resource directory.
wouldn't -initWithUser fail because of permissions? Since every user's Library folder is chmoded 700?
The only way I can think of, off the top of my head, is to save the data in the App's package. Not sure how kosher this is though.
The only way I can think of, off the top of my head, is to save the data in the App's package. Not sure how kosher this is though.
---Kelvin--
15.4" MacBook Pro revA
1.83GHz/2GB/250GB
Saving data in the app's package is not kosher at all, what if your app has been installed by an administrator but is being used by a regular user? Then you won't have permissions to modify your own bundle contents.
Best I can think of is to use /Users/Shared/ as a dumping-ground; not all that satisfactory. Or you could just assume that if people want to compete with each other they won't change users
Best I can think of is to use /Users/Shared/ as a dumping-ground; not all that satisfactory. Or you could just assume that if people want to compete with each other they won't change users
Thanks for all your replies. I'm just going to go with the NSUserDefaults options. I just wonder how people actually do have multi users on their Macs.
I thought if an Application had some system-wide stuff besides preferences, that it could go in Application Support? If you wanted to be really tricky, you could have a means to show the user two kinds of top scores: their scores, everybody's scores (those who use the computer), and best of the best, if they let the program access the internet. That would be pretty darn cool.
I do plan to attempt some kind of internet related features to my game. Best of the best is much easier to do than multiplayer game mode though so I think I will try adding that feature.
Am I right in thinking that the challenge of beating everyone else in the world would encourage someone to play the game more and even the holy grail of producing some more registrations?
Am I right in thinking that the challenge of beating everyone else in the world would encourage someone to play the game more and even the holy grail of producing some more registrations?
There was a thread about internet high-scores here a while back. The basic concensus was that preventing cheating would be difficult, if not impossible.
If you're happy to deal with that or ignore it though, sure!
If you're happy to deal with that or ignore it though, sure!
By cheating I assume you mean me fixing the scores so that no one ever beats me
By cheating I mean anything from submitting absurdly high high-scores to hacking into the system and deleting the ones already there... but it's the submission of invalid scores which is the problem you don't stand a hope of preventing...
I knew exactly what you meant by cheating.
I just did a quick search for the thread but did not find it so I'm sorry if I'm covering old ground again.
The way I would submit the scores is in a losely encrypted format via TCP/IP directly to my server from the game itself. How would it be possible to fake that?
I just did a quick search for the thread but did not find it so I'm sorry if I'm covering old ground again.
The way I would submit the scores is in a losely encrypted format via TCP/IP directly to my server from the game itself. How would it be possible to fake that?
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| High Scores | ChrisPol | 2 | 2,424 |
Aug 22, 2007 05:56 PM Last Post: ChrisPol |
|
| High Scores | kodex | 0 | 1,882 |
Aug 1, 2005 04:39 PM Last Post: kodex |
|
| Saving High Scores | Nick | 7 | 3,693 |
Jun 20, 2005 12:08 AM Last Post: Malarkey |
|

