Playchilla logo

Playchilla Physics Engine

During my summer holidays I spent some time to build a simple AS3 physics engine just to get a hang of how it works.


Simultaneous motion – The Playchilla Physics Engine is simultaneous, meaning searches for the next collision and advances all entities to this point in time after which the collision is resolved. This process is repeated until all collisions have been resolved for a given time interval. The opposite is sequential motion where one object at a time is updated – this is what engines normally since it’s faster but it can result in collision misses.

Continues motion – All motions are dynamically calculated, ie. the time of impact (toi) between objects are calculated and advanced to. The advantage of using continues motion is that simulations will be more realistic as it avoids tunneling and almost eliminates overlaps. The downside is that those tests are more expensive than static tests which can be used for discrete simulation (test objects at discreet jumps).

Spatial Hash – When many collision occur during the same time step things can get ugly especially for simultaneous physics engines such as this one. To reduce the dimensionality we can employ some kind of spatial search so that we don’t need to check every object against every other. After reading up on sweep and prune and spatial hashing I decided to go with the latter since it’s easier to implement. The disadvantage is that it need some manual selection of a cell size. You can find the implementation here.

Ray casting – Support of simple ray casting methods.

Well designed – Says the designer…

Limitations and missing features

Oh, hrmm, yes, there are some limitations I better mention:
Shapes – Right now it only supports two shapes – circles and rectangles. I decided to start easy but keep design open for adding any shape.
No rotation – What no rotation??? …well after all I wanted to get out in the sun during my summer vacation, so I let go of the rotation.
Weak impulse solver – Item stacking tend to work bad.
No joint support – Not much to say. Really. Read on.

So what can this be used for?

In this state it will probably work reasonable well for billiard games or some simulations that may benefit from simultaneous motion. It could also help developers to understand the nuts and bolts of physics engines. I tried to design it well at least.

However I would recommend you to go for Erin Cattos Box2D or Scott Lembckes Chipmunk or Bullet Physics Library if you want a free powerful engine.


Yeah, right, here is a small demo. Move the mouse to play around.

Get Adobe Flash player


To make it somewhat more useful, rotation needs to be added and probably hybridize it with sequential motion to speed it up. It’s probably nice if convex shapes can be used as well. Not sure where to take it from here, there are already good physics engines out there and not sure if this one would have any edge. I may throw it up as open source and see what happens.


    […] I wrote the Playchilla Physics Engine last summer I needed a broad phase algorithm to reduce the number of collisions to check. There are […]

  • Hey, have you ever done anything with this? I am working right now on some very basic 3D physics (really, they need little more than what I see in your 2D implementation) for isometric games, and the simultaneous motion intrigues me. Is this something that could also be ported to c# server side code? Any information would be appreciated. You can see what it is I am working on at Thanks!

    • Hi! I’ve not done much with it, just a few experiments. I like your game idea! I am sure porting it to c# is pretty straight forward. I’vent put out the code anywhere, but if you want I can email it to you?

    Where can I download it 😛

    • Sorry I never got around to make it downloadable..