I’ve implemented a simple dynamics engine in C# that simulates 2D physics using Verlet integration.  It’s based on a project called Flade, written in Actionscript (for use in Flash/Flex) by Alec Cove.

This implementation adds some simple particle/particle collision (Flade does particle/fixed surface collision right now) and uses WPF for rendering.  It uses the same ItemsControl and data binding approach as my earlier stuff.

Because it’s all in C# it was easy to build it into an XBAP for deployment.  Click the image below to try it out!

Press left and right arrows to move the “car”.  Pressing the up arrow can sometimes get you out of a jam (you can also try driving up the wall)…  Try not to hit F5 (refresh) too often as it seems to slow the whole thing down (I’ve not looked into why yet).

Obviously this is a work in progress.  If you look closely when the wheels collide you’ll notice a green marking appear; that’s just showing the location and depth of the collision for debugging (the deeper the collision, the longer the green mark).

I’ll post updates (and source code) as I go along :o)

About these ads