Facebook Game – Mountains out of Molehill

Facebook Game - Mountains out of MolehillSorry for the gratuitous pun but I couldn’t resist ;)

I’d been meaning to do this for a while but this weekend I replaced my BitmapData based renderer for my game with one that utilises the new hardware accelerated graphics of Flash Player 11 (formally Molehill). Rather than getting into the low level code required to make a custom renderer I decided to use one of the 2D frameworks that the Flash community have come up with. I chose the excellent ND2D by Lars Gerckens because it seemed to have all the features I’d need and the demos blew my socks off (press space to cycle through the demos on that page)! I like Lars’ implementation of Sprite Clouds (a group of sprites with a common texture), they work perfectly for game entities like projectiles and particle effects.

My renderer is un-optimised (I was eager to get something up and running as soon as possible without doing too much refactoring) and I’ll be making some changes to bring the game more in-line with the ND2D display list paradigm, but I think its a good start. I’ve noticed a huge performance boost already, the game is running at a smooth 60fps on my PC now. The next step will be to up the game viewport size as this was previously limited by how many tiles I could render every frame using BitmapData.copyPixels() without performance suffering. I’ve also noticed that screen tearing has completely disappeared (it was a real pain when using the BitmapData method).

If your planning to get involved with Flash Player 11 game developement then there are a few things to bear in mind when designing your application structure. The biggest one is that all Stage3D content is rendered on a layer (or layers) below the main flash stage. So, regardless of where your ND2D world is added to the display list, your game content will be behind all other display objects. As a result you need to cut a hole through all display objects that make up your UI (backgrounds etc) so the Stage3D content can shine through. Another thing thats worth implementing from the get-go is a time based (rather than frame based) update system. This is standard game dev practice but I’ve only just got into it. Instead of moving items the same distance every frame (I believe) it is better to move items based on the time since the last frame was rendered. All ND2D sprites have a step() method that accepts an ‘elapsed’ parameter. The ‘elapsed’ param is the number of seconds since the last update and all movement should be based on that (“sprite.x += 1 * elapsed” rather than “sprite.x += 10″). The resulting movement is much smoother as it compensates for variation in the number of milliseconds between updates caused by CPU/GPU usage.

Dabbling with this framework has got me really excited about the possibilities that will arise when this version of Flash Player penetrates through the market enough to start using it for client projects!

Facebook Game – Work In Progress

Facebook Game - WIP
I’ve been working on this game for some time now. Its a twin stick shooter in which players settle a land and then defend it from attacks whilst attack lands owned by their Facebook friends. The graphics engine uses BitmapData blitting to render large numbers of assets quickly. The system generates landscapes using perlin noise which can be seen in this render of possible lands – http://www.flickr.com/photos/tomdanvers/5765825135/lightbox/. I’m allowing players to see my work in progress builds so I can get feedback as the game progresses.

http://apps.facebook.com/re-source/

DICE 2010 : ‘Design Outside the Box’ : Jesse Schell

FarmVille

Carl pointed me in the direction of this excellent presentation by Carnegie Mellon University Professor Jesse Schell. For anyone working in digital who has been asked by a client to make a Farmville clone this is a must-see video. Schell talks about the Facebook game phenomenon (Farmville, Mafia Wars etc.) and how its taken the games industry by surprise. He points out the success of these games is their interaction with the real world. The traditional idea of games as an escape from reality is therefore being turned on its had by this new wave of casual social games. Players now want their game experiences to be interwoven with real life and their day to day interactions with friends and strangers. Achievement based gaming is a good example of this idea, players get bragging rights and even single player experiences become competitive. He also talks about revenue streams in these games. Schell points out that games that require direct payment often generate less revenue than games which are totally free to play but use micro transactions or subscriptions to unlock enhanced game feaures.

His talk also inspired me to think about what else makes a successful casual game. I’m sure its been commented on before but I’ve noticed that my personal enjoyment of a casual game is often related to the ratio of active to passive gameplay. What I mean by this is the amount of time you as the player have to be interacting with the game in order to progress. Contrary to what I used to think its often games with an even split of active and passive gameplay that are the most fun. Take Peggle for example. In Peggle you line up the trajectory of the shot and then hit Fire, then you watch your action play out which can easily take 10 seconds or more. The same goes for Angry Birds, you shoot your bird and watch the physics engine do its work. This mechanism works particularly well on mobile devices, it means the player is never penalised for pausing in the middle of a game session. It also makes the effort involved in playing quite low which encourages ‘just one more go’ behaviour.

I’ve embedded the talk via G4TV.

EDIT : Jim Rossignol has posted an interesting response to the Schell video on RockPaperShotgun.