High Scores
I’ve been thinking about high scores and how that should be implemented in a game. If you are only concerned about local scores that can be done using NSUserDefaults or you could use a sqlite database. Those are fairly easy to implement.
Local scores though are limited in use. They are good if you want track your personal best effort in a given game. How many other people use your iPhone/iPod and would play a given game? Probably not many; maybe none.
Global/Internet based scores are more interesting. I think it encourages people to play games more due to competition with other players. That can help word of mouth sales, if someone likes your game(s) and they get their friends to buy it and see who is the best.
The more people playing your games can create more opportunities to sell in app purchases. You can obtain better metrics of who is playing your games and how they are doing (Is it too easy? Too hard? etc.),
Long term it’s not hard to see Apple putting something together like XBox Live that developers could plug into for these purposes.
Today you are on your own. I did see one open source system called iGetScores. The server side is written in PHP with a MySQL backend. It uses OAuth. The client code is not small and you’d be adding around 40 files to your project. It seemed to be more complicated that it should be.
I wanted something simple and am looking to writing my own.The basic requirements would be to accept new high scores and to be able to get a list of them for a given game. From a security point of view, accepting data from random users into your database can be an issue. You need to consider people trying to use SQL Injections or denial of service attacks. You have to deal with people who might try to cheat and put in false scores.
I was thinking about having a shared secret where by the iPhone/iPod that wants to submit a score, encrypts the data with a shared secret and sends to server. The server then decrypts the data and inserts into the database after some validation. Depending on encryption used that might cause export issues for some countries.
You could use the UUID of the iPhone/iPod to keep track of submissions from people and use the date/time of the request to see if that person has submitted anything before. If someone tries to post multiple scores within a few minutes and you know your game would take at least X number of minutes to complete, you could throw that out as a fake.
I’m still thinking it through and I don’t have a full design yet. I’m still flushing things out. I’ll have more to say about this later and maybe some code too.
To be continued…