High Scores in Cocoa

Moderator
Posts: 592
Joined: 2002.12
Post: #1
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,
Quote this message in a reply
Member
Posts: 104
Joined: 2002.04
Post: #2
I've tried it both ways, and I think its best in some user defaults
Quote this message in a reply
Moderator
Posts: 592
Joined: 2002.12
Post: #3
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?
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #4
There would be a different high score for each user.
Quote this message in a reply
Moderator
Posts: 592
Joined: 2002.12
Post: #5
Is there a shared equivalent of user defaults? Or am I maybe being a bit fussy for a game high score table?
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #6
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. Grin
Quote this message in a reply
Member
Posts: 469
Joined: 2002.10
Post: #7
wouldn't -initWithUser fail because of permissions? Since every user's Library folder is chmoded 700?Blink

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
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #8
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 Wink
Quote this message in a reply
Moderator
Posts: 592
Joined: 2002.12
Post: #9
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.
Quote this message in a reply
Feanor
Unregistered
 
Post: #10
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.
Quote this message in a reply
Moderator
Posts: 592
Joined: 2002.12
Post: #11
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?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #12
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!
Quote this message in a reply
Moderator
Posts: 592
Joined: 2002.12
Post: #13
By cheating I assume you mean me fixing the scores so that no one ever beats me Rasp
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #14
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...
Quote this message in a reply
Moderator
Posts: 592
Joined: 2002.12
Post: #15
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?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  High Scores ChrisPol 2 2,596 Aug 22, 2007 05:56 PM
Last Post: ChrisPol
  High Scores kodex 0 2,056 Aug 1, 2005 04:39 PM
Last Post: kodex
  Saving High Scores Nick 7 4,113 Jun 20, 2005 12:08 AM
Last Post: Malarkey