I have created a short video preview of my next upcoming game. It is a word game that requires you to match colored bubbles to collect letters. With those letters you form words and score points. It allows you to compete with your facebook friends for the highest score. It includes two game modes, timed gameplay and endless gameplay.
One of the challenges for my next upcoming game is Facebook integration and leaderboards. I was looking for a simple way to associate a Facebook user with a leaderboard and a score. I wanted to keep it as SIMPLE as possible and do it as CHEAP as possible, so I turned to Linux, PHP and Redis.
Redis (http://redis.io) is an open source key-value store. This would be the simplest method for storing high scores for my game. To save a score I would just have Redis “SET” the score. For instance, using the user’s Facebook UID I would save a score of 1000 for leaderboard “A”. In Redis I would run: SET UID12345_leaderboardA 1000. Then to retrieve the score just “GET” it. (GET UID12345_leaderboardA). This took no time to setup but having Redis open to the world would not be a great idea. This is where PHP comes in to play…
PHP is a web scripting language (http://php.net) used on TONS of web sites. In order for PHP to communicate with Redis I grabbed Predis (https://github.com/nrk/predis) from GitHub and included it in my script. I threw together a simple script that uses a hash to help keep things more secure. The script is listening for a PUT or a GET request method and based on the method knows whether to SET or GET the score from Redis. The user data (key and score) are JSON encoded in the body of the request.