Home Games Blog About About Twitter Youtube
Flash Multiplayer P2P Physics Concept
Written by Matthias   
Friday, 30 December 2011 00:11

 

So taking a break from working on a content update for Super Ninja Skydiving Plus Zombies I desided it would be cool to play around with some multiplayer stuff.

 

So I started by doing some research on p2p connections within flash. I came across a blog post on Tom Krcha's website. The post can be found here (http://www.flashrealtime.com/p2p-game-lib/). He was nice enough to make available the source to his p2p game library for use with the Adobe's Cirrus service.

 

Cirrus is a beta Adobe service that allows you to connect 2 or more clients together with a p2p connection using Adobes rtmfp protocol. So all the server does is allows the handshake to happen, the rest is all p2p connections handled within flash.

 

I really hope Adobe keeps Cirrus free or low cost to allow developers to create some awesome multi-user content without the cost of having a dedicated server.

 

So once I knew how the p2p connection could be made I wanted something to test it with. So I grabbed the Box2D World Construction Kit (http://www.sideroller.com/wck/) and plugged away. At first I thought about syncing all kinds of physics data to make everyone connected see the exact same world. I ended up just sending the the players data. For the most part this does the trick and allows you to do some neat stuff. In the future I will be sending data for objects that have made contact with players but that's not in there currently.

 

The result is 2 nights of programming. I was able to get a small level that can accept multiple users and sync their locations pretty accurately for the most part.

 

Check out the project by clicking on the screenshot below.

 

p2pPlusPhysics

 

Not sure if I'm going to release the source for this example. The code was put together fairly quickly and is a bit messy and uncommented. If you take a look at the 2 links I posted you could have all the info to recreate a similar project without too much trouble.

 

Known issues:

  • Sometimes it takes a second for a new connected players position to update
  • Objects in the level will not be synced if a player connects after some have already been interacted with
  • There are a few minor syncing issues but for the most part it plays pretty smoothly
  • When a player disconnects his ninja does not disapear

 

 

 

 
 
Home   |   News   |   Games   |   Blog   |   About   |   Links   |   Login         © Copyright 2011 Rybram.com
Login