Thursday, January 10, 2008

Actionscript 2D Physics Engines : FOAM

This post is part of a series reviewing the available Actionscript 2D Physics Engines. Each engine was tested through the development of three simple simulations; Hello World, Rope Bridge and Stunt Bike. You can find out more about the testing methodology and access the other reviews from the introduction post.

APE Bridge screenshot

FOAM isn't quite as easy to use as APE but it is still easy to use. Once again there is good documentation and some useful demos. Of all the engines I think it is the one most in tune with common Actionscript 3 development techniques and hence will look most familiar if you've spent much time with AS3 development. As the screenshot shows it offers a lot more options for adding different shapes to your simulation. For example, every shape in the screenshot (except for the circle) was created using ShapeUtil.createSymmetricPolygon(sides,size). Foam also doesn't require an enterFrame function to update the simulation. Instead you call foam.simulate() and it looks after stepping through the simulation.

So far so good. FOAM had no trouble making the Hello World simulation. Unfortunately, the news is not good for the Rope Bridge simulation. FOAM offers two types of constraints and these both offer some useful properties but at the end of the day I was unable to configure them in a manner that would create my Rope Bridge. The two joined objects were always too far away from each other. So my bridge always ended up looking more like an alpine rescue mission. Perhaps I'm missing a vital element here. It's hard to know. FOAM is the only engine that doesn't have some kind of bridge in the available demos. That could be because a bridge isn't possible at this stage or that it wasn't deemed of interest for the demo. It is worth noting that FOAM is an 0.1 alpha release. I'm sure there is still a lot of work to be done before it reaches a beta state.

In summary, FOAM looks very promising. It's simple to use and flexible with good documentation but I imagine it is still too immature to be used for anything at this stage.

No comments: