Menu:

Sponsor

Discover Master of Alchemy, our first iPad/iPhone and iPod touch game!

Follow Me

 

Forum's topics

Latest Files

Archives

Top Rated

Categories

Photo Gallery


Alessandro Crugnola on July 13, 2005 in actionscript

Flade, opensource 2D physic engine

Today Davide shows to me this link to a new opensource project regarding Flash.
It's a "free library for simulating 2D physics in Flash using Verlet integration. It currently features particles, stick & angular constraints, wheels, and surfaces composed of line segments. Designed primarily for games with a goal of speed and ease of use"

I immediately downloaded the available "alpha" release and made a first test..
Take a look at the swf

I don't know if the project is still alive and which is the developement status, but it looks very promising.


...And here the code used for the example above:


var psystem = new ParticleSystem();
psystem.setDamping(1.0);
psystem.setGravity(0.0, 0.4);
// cooefficient of restitution
psystem.setKfr(0.1);
// surface friction for particles
psystem.setFriction(0.5);

// surfaces
var sA = new Surface(new Point(0, 0), new Point(1, 200));
sA.setIsOrientH(false);
psystem.addSurface(sA);
var s0 = new Surface(new Point(1, 200), new Point(100, 200));
psystem.addSurface(s0);
var s2 = new Surface(new Point(220, 170), new Point(300, 200));
psystem.addSurface(s2);
var s3 = new Surface(new Point(300, 200), new Point(400, 150));
psystem.addSurface(s3);
var sB = new Surface(new Point(399, 150), new Point(399, 0));
sB.setIsOrientH(false);
psystem.addSurface(sB);

// circle surface
var circA = new CircleSurface(170, 220, 70);
psystem.addSurface(circA);

var leftX = 10;
var rightX = 50
var widthX = rightX - leftX;
var midX = leftX + (widthX / 2);
var topY = 160;
// wheels
var wheelA = psystem.addWheel(leftX, topY, 10);
var wheelB = psystem.addWheel(rightX, topY, 10);
wheelA.coeffSlip = 0.0;
wheelB.coeffSlip = 0.0;
// body
var rectA = psystem.addRectangle(new Vector(midX, topY), widthX, 10);
// wheel struts
var conn1 = psystem.addConstraint(wheelA.wp, rectA.p3);
conn1.setRestLength(5);
var conn2 = psystem.addConstraint(wheelB.wp, rectA.p2);
conn2.setRestLength(5);
var conn1a = psystem.addConstraint(wheelA.wp, rectA.p0);
conn1a.setRestLength(5);
var conn2a = psystem.addConstraint(wheelB.wp, rectA.p1);
conn2a.setRestLength(5);

psystem.paintSurfaces();

this.onEnterFrame = function() {
var keySpeed = 2.0;
if(Key.isDown(Key.LEFT)) {
wheelA.rp.vs = -keySpeed;
wheelB.rp.vs = -keySpeed;
} else if(Key.isDown(Key.RIGHT)) {
wheelA.rp.vs = keySpeed;
wheelB.rp.vs = keySpeed;
} else {
wheelA.rp.vs = 0;
wheelB.rp.vs = 0;
}

if (Key.isDown(Key.UP)) {
if (ang.targetTheta < 2.9) ang.targetTheta += .1;
} else {
if (ang.targetTheta > angDefault) ang.targetTheta -= .1;
}
psystem.timeStep();
psystem.paintWheels();
psystem.paintConstraints();

}

 

Bookmark and Share

 

 

3 comments
Hey riaan, The project is kinda dead, but you can check out a simple tutorial over at our blog. http://www.dreaminginflash.com/
Hey there! Any more word on this? Is the project still alive? I too would love some sort of basic tutorial on how to use - woudl be great! Anyways, laters. Riaan
I would love to see more about Flade in form of a tutorial, or explaning the syntax a little better. I am having a hard time adapting to the way flade works.


Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)


Type the characters you see in the picture above.





 

TrackBacks

TrackBack URL for this entry: http://www.sephiroth.it/cgi-bin/mt/mt-tb.cgi/49