Fans of one of our recent blogs
will know that when we release a game on a particular platform, such as Steam, we like to make use of the functionality that is made available to us to enhance the user's social gaming experience. In the case of Steam, this includes achievements and leaderboards and all the related gamer comparisons that come with them. We utilized both in On A Roll 3D
. The Steam community were generally happy that we'd done this - extending the naturally competitive nature of games from just the individual to their friends and the wider gaming community proved popular.
So, when we decided to release On A Roll 3D on iPad and iPhone, we investigated adding support for Game Center - iOS's answer to a social gaming platform that is designed to rival Steam, Xbox Live and so on. Here's a bit about our experiences from the development side of the fence...
Game Center uses a familiar model for achievements in that they can be set up in iTunes Connect with a name, description and number of points, and their progress can be updated in the form of a percentage during gameplay. This is all very easy to do - a single line of code sets the progress of an achievement, and if that progress is set to 100%, the achievement is automatically awarded, and the UI shows a notification. All very straightforward.
A Game Center achievement being awarded in On A Roll 3D
We had few troubles implementing leaderboards either. After setting them up on iTunes Connect, it was just a case of posting a score/time to the relevant leaderboard and Game Center does the rest. It even includes a leaderboard UI that can be displayed with a single line of code for navigating through the various scores on the game's various leaderboards. From our point of view, it was very much a "post and forget" situation, which made our lives somewhat easier.
This is where we hit a bit of a snag. Steam and Xbox Live have the concept of "Stats" for storing progress, which can be linked to achievements. For example, we have an achievement in On A Roll 3D for scoring a total of 250,000 points. In Steam we set up a stat to store the total number of points scored and linked it to the achievement so it automatically unlocked when this threshold was reached. In Game Center, all we have is an achievement percentage which is unfortunately rounded to the nearest whole number, so we can't store progress in Game Center in this way.
Sure, we could store the progress elsewhere, such as locally on the device itself. But what if someone wanted to run the game on their iPad and their iPhone using the same Game Center account? They would expect their progress to sync between the devices, and for them to be awarded achievements on either device. Or what if they re-installed the game? They wouldn't expect to have to start over unlocking levels and collecting items, especially if they've already gained half of the achievements.
We did eventually find a workaround for this. It is possible to store a 64-bit context value against each leaderboard entry. By having a leaderboard for the total number of points a player has ever scored, we were able to encode some additional achievement data in the context value for this entry and read it back in when the game is started on any device. By comparing this encoded data to what is stored locally, we can gain an accurate picture of the player's progress. 64 bits was enough to store level progress and the progress of various achievements (remember, we still had the 0-100% progress value off each achievement which was sufficient for some of them). It was essential that the leaderboard was for all-time scores, because the context value only updates when a new entry is posted, and the all-time score will only continue to rise over time.
Game Center takes a bit of work to implement, and it can be frustrating to find that it can't be used to store progress, other than the hacky way of using leaderboard context values mentioned above. Despite this, it's worth the effort, and I'm sure we'll be able to implement it much more quickly for future games now that we've got our heads round how it works. In our experience it's generally worth making the effort to use all the social elements a gaming platform has to offer. Many gamers like its competitive nature.