What’s more fun than popping balloons? Last week at CouchConf SF, we demo’ed an experimental social game app (Pop-it) powered by Couchbase Server 2.0 (Beta). It is a HTML5 browser app with a C#.Net game server.
http://www.youtube.com/watch?v=13nCv_AMCi0 Microsoft Kinect Sensor
var gameResult = new GameResult { Name = name, Score = score };
//Create a timestamp key
TimeSpan t = (DateTime.UtcNow – new DateTime(1970, 1, 1));
int timestamp = (int) t.TotalSeconds;
//Call the StoreJSON client method to store the score in Couchbase
m_cclient.StoreJson(StoreMode.Set, timestamp.ToString(), gameResult);
The map function emits the score of the player and the name of the player. The C# application can query the view, sort it using the descending modifier and limit the number of results (top 10 players in this case).
public ActionResult Index () {
var view = _client.GetView(“scoreboard”, “by_score”, true).Descending(true).Limit(10);
return Json(view.ToArray(), JsonRequestBehavior.AllowGet);
}
Congratulations Pop-It champions!