Psyked *
it’s easy once you know how.Simplifying Box2DAS3…
Posted by James - 08/01/10 at 09:01:15 amOne of the downsides to the Box2DAS3 project – and probably one of the major hurdles to most Flash developers – is the fact that it’s inherited a lot of the syntax from the C++ project that it’s derived from. Maybe it’s just because we’re used to it, but Actionscript is pretty easy to understand, and its methods of working pretty tolerant of inefficient coding.
C++ – or whatever Box2D is written in – is not, and it’s a little painful to setup and easy to break. For my sanity as much as anyone else’s I’m working on a set of classes in AS3 that wrap around the Box2DAS3 classes, and provide you with a more familiar syntax for working with Box2D – objects, methods and utilities that makes it quicker to throw things together and don’t require you to rethink the way you work.
Well, that’s the eventual aim anyway.
Here’s the result of the first round of development – creating a Box2D world and adding objects, in about 6 lines of code.
var options:Box2DWorldOptions = new Box2DWorldOptions( 500, 280, 30, 9.8 );
options.setWorldEdges( true, true, true, true );
var world:Box2DWorld = Box2DUtils.createBoxedWorld( options );
world.debugDraw = true;
world.animateOnEnterFrame = true;
addChild( world );
for ( var i:int = 0; i < 30; i++ )
{
world.createCircle( 500 * Math.random(), 280 * Math.random(), 50 * Math.random());
}
And here’s the result:
Continue reading Simplifying Box2DAS3……
The results of my annual “code something different this Christmas” idea.
Posted by James - 04/01/10 at 09:01:39 amIt’s becoming something of a tradition now I guess, but once I’ve allocated that extra Christmas holiday time appropriately, I find I have that little bit of extra time to devote to trying something new. This year, I thought I’d try rewriting (again) one of my old university experiments.
Here’s the result:
It’s pretty. I won’t even try to explain the idea behind it, but it’s basically an attempt at simple life simulation, with some AI governing the actions. This time around I’ve built it with the aid of Box2D, so all the movement, impacts and interaction is achieved by punching some figures into the Box2D world, which makes the thing a helluva lot easier.
The big plus of “trying something new”? I now have a basic understanding of trigonometry! I didn’t even have to Google anything!



