1 Star2 Stars3 Stars4 Stars5 Stars
Loading ... Loading ...

Simple Box2D – Better, cleverer, more optimised.

^ This time, that’s an image – saves on the page rendering time!

Another update on the Box2D classes I’m working on.  No new features, but some pretty cool expansions and improvements to the library object creation.

If you check out the previous post, you’ll see that the the dynamically drawn shapes weren’t exactly perfect; nor were they very efficient.  Oh they worked fine, and traced the detail of the shape very well – but it took a decent chunk of system resources to animate and ended up with some overlaid shapes; which all made the Box2D a bit sluggish and the behaviours buggy.

So, stealing incorporating ideas from other projects has been the name of the game – namely the ear clipping optimisation code from Splashdust.net, combined with some of my own cobbled-together more optimised code for tracing curved edges.

Live demo:

Mouse interaction is enabled in the below example – click and drag the objects to check out how it works.

Download the source code for this demo.

* The source code isn’t exactly cleaned up – sometime, eventually, it will be.

2 Comments »

  1. insanely useful!! thank you :)

    Comment by chichlatte — 9 February 2010 #

  2. Thanks!

    I’ve just managed to get the source files for this demo on GitHub: http://github.com/psyked/Simple-Box2D

    Where I’ll endeavour to keep all the source files from now on!

    Comment by James — 10 February 2010 #

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Note: This post is over a month old. You may want to check later in this blog to see if there is new information relevant to your comment.