A few weeks ago I had the idea of creating a multiplayer Flash game, using the new peer to peer connection capabilities of FlashPlayer 10. Here is the result.
Building a multiplayer game comes with it’s own set of challenges. The first one being the initial creation of a p2p connection, which basically comes down to four steps:
- Connecting to Adobes Cirrus server (formerly Stratus) using a personalised Cirrus server address and a developer key. For more info click here: http://labs.adobe.com/technologies/cirrus/
- Receiving a peer ID from the Cirrus Server.
- Sending that peer ID to the second Player.
- Sending the peer ID from the second Player to the Cirrus server.
I decided to simplify that process by using SWFAddress, creating a custom URL + peer ID that could be send to the second player. This prevented him from being forced to re-enter the peer ID into his client. After that you have to find a convenient way of sending the game URL to the second Player.
In a second step I would have tried to add a social media component to the Game. For example: Using a Twitter login to start and immediately publish a game request.
Since debugging and testing the game is somewhat of a hassle, I decided to stop development on it. You can however download the complete source code from here:
DOWNLOAD – P2PShooter (204 KB)
Before you start editing the code, be sure to get a Cirrus developer key and connection URL first (see step 1).
Insert your developer key and server address into the static constants in MPShooter.as.
To compile the Game use the MPShooter.as in the package de.davidochmann.games.mpshooter (I used FDT, but Flash Develop should work fine to). Using FlashPlayer 10 as target player is required.
Please be aware that the game in its current state is a proof of concept. There aren’t a whole lot of code comments, and some approaches aren’t very good (e.g. try using registerClassAlias instead of relying on the anonymous Data object).
Very cool stuff there isn’t enough of this on the Internet THANKS
Comments are closed.