informa
2 MIN READ
Blogs

Pop-It - A Social Kinect Game Powered by Couchbase Server

What’s more fun than popping balloons? At Couchconf SF 2012, we demo’ed an experimental social game app (Pop-it) powered by Couchbase Server 2.0 (Beta). Check out the game in action - http://www.youtube.com/watch?v=13nCv_AMCi0

What’s more fun than popping balloons?  At Couchconf SF 2012, we demo’ed an experimental social game app (Pop-it) powered by Couchbase Server 2.0 (Beta). Check out the game in action - http://www.youtube.com/watch?v=13nCv_AMCi0

Now that you’ve seen how addictive this game can get, let me get into how it actually works!

The game server senses hand joint locations using the Microsoft Kinect Sensor and streams the coordinates of the hand joints to the client using websockets. The client renders balloons using javascript and performs collision detection between the balloon objects and the hand joint points. Basically, you touch the balloons to pop them and gain points. At the end of the game, Couchbase Server is used to store the player points. The client sends the score and player name to the server and the C# application writes this data into Couchbase.

To store the score, we create a GameResult object as shown below:



Then using the C#.Net client for Couchbase Server 2.0, we write this data into Couchbase Server using:

var gameResult = new GameResult { Name = name, Score = score };

//Create a timestamp key 
TimeSpan t = (DateTime.UtcNow - new DateTime(197011)); 
int timestamp = (int) t.TotalSeconds; 

//Call the StoreJSON client method to store the score in Couchbase 
m_cclient.StoreJson(StoreMode.Set, timestamp.ToString(), gameResult);

Now that the score is stored in Couchbase Server, by using the indexing and querying features in 2.0, a real-time leaderboard can be generated so that players can track their progress. The map function to create a leaderboard in Couchbase Server looks like below: 



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); 

}

Feel like playing? Download the code here, compile it and enjoy ! (If you don’t have a Kinect, no problem, mouse-clicks on the balloons also work). Here are the top players from CouchConf SF. 

Congratulations Pop-It champions!

Latest Jobs

Xbox Game Studios

Redmond, Washington
10.5.22
Technical Lighting Artist

Innogames

Hamburg, Germany
10.5.22
Game Designer - Elvenar

Six Foot

Houston, TX
10.3.22
Six Foot Director, Player Relations

Hometopia Inc.

Remote
10.7.22
Lead Engineer
More Jobs   

CONNECT WITH US

Explore the
Subscribe to
Follow us

Game Developer Job Board

Game Developer Newsletter

@gamedevdotcom

Explore the

Game Developer Job Board

Browse open positions across the game industry or recruit new talent for your studio

Browse
Subscribe to

Game Developer Newsletter

Get daily Game Developer top stories every morning straight into your inbox

Subscribe
Follow us

@gamedevdotcom

Follow us @gamedevdotcom to stay up-to-date with the latest news & insider information about events & more