Tips For Developing Facebook Games

The Facebook Platform has created a whole new market for online games and start ups such as the Social Games Network (SGN) and Zynga. I wrote about developing Facebook Applications a while ago as a overview of my experiences. Some of my apps are games and some are not - I'm a game developer so I prefer making games.

While going through my blog traffic data, I saw search terms specifically about developing games on Facebook. That leads me to believe that someone is looking for information about that. I have some of that knowledge to share!

I generally make games for Facebook using Flash and ActionScript. There really isn't a good way to make really interactive games using web languages and Flash is fairly powerful for 2D casual game experiences. You can find a list of the Facebook games that I've made or had a hand in from my developing Facebook Applications article.

There are basically three real games on that list: FlipCup Challenge, Sam's Solitaire, and Sheep Tycoon. Sheep Tycoon is by far the prettiest because there was a real artist on that project - the other two I just slapped some art together to get the game out quickly. I'm not really an artist.

Using Facebook API From Flash

Figuring out how to best make calls to the Facebook API from Flash was one of the first things we had to deal with. In Sheep Tycoon, the high score table shows up in the Flash part of the game opposed to FlipCup or Sam's Solitaire where I just did it in PHP. There are a whole bunch of Flash Facebook API's - I didn't like any of them.

The solution we came up with is to make a 0x0 iframe - basically invisible - on the canvas page and load a PHP script that would do all the Facebook API calls. So, if we needed to add a new high score to our database, we would load the script in the invisible iframe. This works for sending notifications or doing any sort of Facebook API call.

Getting the Friends

Although I didn't find doing this all that complicated, I did see a search term for it in my traffic data. The easiest way to accomplish this is to just get the user's friend ID's in PHP and then passing it into the game using flashvars. I don't see many cases where the user's friend list will change while the game is being played. Once you have the friend ID's in the game you can do whatever you want with it. We used it to show the list of your friend's high scores in Sheep Tycoon.

The game takes the friend ID's from flashvars. When we need to get the high scores, we pass the same ID's to our PHP script that does all the database work and then returns the data in XML form for Flash to read.

Dealing with High Scores

You can display the high scores inside the game or you can display as a PHP page. I will generally opt to do the latter because there are less steps involved. PHP will get the data and display the data while Flash has to call a PHP script to get the data and then display it. However, displaying the high scores as part of the game itself is a better experience.

The semi-tricky aspects with high scores is how to record them and assign global ranks to each player. I've used time as a tie-breaker for scores that are identical. If you got the score first, you will stay above the person who got the score second. MySQL has been our database of choice and you can use ORDER BY with more than one field so it would be: ORDER BY score, time.

In FlipCup Challenge, each user has a global rank that is determined by their high score. This rank changes as players get new high scores. Updating everyone's global rank every time someone managed to get a new high score didn't seem like a good idea.

Firstly, to calculate the global rank, I figured out the number of rows that had a score higher than the score we are looking to get a new rank for. With that information, we'll know that the rank will be something lower than the row count. We then find all the scores that are the same as the score we are using and then determine where it fits in there. With those two pieces of information we can calculate the right rank.

In order to make sure the scores are correct when anyone goes to look at the Scoreboard in FlipCup, we also update the ranks of all your friends when your rank changes. Global ranks are also recalculated every time you view the Scoreboard page. This will ensure that all the global ranks will be correct when someone is viewing it.

I'm sure there are better ways for determining global ranks than this but, for FlipCup's purposes, it works fine. The main objective was to make sure the pages loaded fast so the code had to do the work quickly.

Experiment

Game development on Facebook is still in infancy. I'm not aware of many sites dedicated to providing information about games and Facebook. The games themselves are still rather primitive as most don't really tap into the potential of social networks. I believe social networks are a powerful tool that can help spread new games and game ideas.

I have not looked much into development on the "new" Facebook even though I have switched to it and my links above point to the new Facebook. My apps are still working fine so I am not too concerned. The marketing and growth of apps are going to be affected. The chance of a Zombies-esque app prol

 

Now Pay Close Attention --Using your Facebook Fan Page to increase your business exposure and revenue is simpler than you've been told. Everyone with a facebook fan page faces the same two problems:

[Problem #1] How To Find Interested Facebook Users

[Problem #2] How To Bring Them To Become Your Fans

Facebook Fan Supply has been solving these two problems for hundreds of satisfied customers. The Facebook Fan Supply has been tried and tested and known to produce excellent results.First: Click Here To Visit Facebook Fan SupplyFacebook Fan Supply always supplies REAL FANS targeted to your specific: Age Group, Keyword and Location.Second: Order Your Facebook Fan Supply Package of 1,000; 2,000 or 5,000 Guaranteed Facebook FansYour new fans will arrive in 3 - 4 weeks and all fans are REAL FANS guaranteed to stick to your fanpage. Buy Facebook Fans today and boost your businesses online presence overnight.

With over 500 million users, Facebook is by far the greatest marketing arena online. But to take advantage of this amazing tool, it is always a good idea to get a head start on your competition and Buy Facebook Fans. Visit http://www.fbfansupply.com and claim 25 FREE FANS for tweeting about Facebook Fan Supply!

, , , , , , , , ,

No comments yet.

Leave a Reply