Author Archives: Zevan

QuickBox2D Floating Walker

CLICK HERE TO COPY
Actionscript:

import com.actionsnippet.qbox.*;

import Box2D.Common.Math.*;

import Box2D.Dynamics.Joints.*;

 

[SWF (backgroundColor=0x000000, width=700, height=600, frameRate=60)]

 

var sim:QuickBox2D = new QuickBox2D(this, {gravityY:.2});

 

sim.setDefault({fillColor:0xEFEFEF, fillAlpha:0.5, lineColor:0xFFFFFF});

 

sim.createStageWalls();

 

for (var i:int = 0; i<20; i++){

    sim.addCircle({x:1+i, y:1, radius:0.2, restitution:1});

}

 

var head:QuickObject = sim.addCircle({x:0, y:0, radius:0.5});

var neck:QuickObject = sim.addBox({x:0, y:1, width:0.5, height:2});

var top:QuickObject = sim.addGroup({objects:[head, neck], x:10, y:5, fixedRotation:true});

 

var upperLegA:QuickObject = sim.addBox({x:10, y:7.5, width:0.25, height:1.5,groupIndex:-2});

var lowerLegA:QuickObject = [...]

Posted in Box2D, QuickBox2D, motion | Tagged , , , , | 1 Comment

QuickBox2D Prismatic Joint

CLICK HERE TO COPY
Actionscript:

import com.actionsnippet.qbox.*;

import Box2D.Common.Math.*;

 

[SWF (backgroundColor=0x000000, width=700, height=600, frameRate=60)]

 

var sim:QuickBox2D = new QuickBox2D(this);

 

sim.setDefault({fillColor:0xCCCCCC, lineColor:0x3355AA});

 

sim.createStageWalls();

 

var box:QuickObject = sim.addBox({x:10, y:10, density:0});

var circle:QuickObject = sim.addCircle({x:10, y:13});

 

sim.addJoint({type:"prismatic", a:box.body, b:circle.body, axis:new b2Vec2(1, 0), upperTranslation:3, lowerTranslation:-3, enableLimit:true, motorSpeed:10, maxMotorForce:10, enableMotor:true});

 

sim.start();

sim.mouseDrag();

Simple prismatic joint demo. Prismatic joints are odd, it took me awhile to realize how to use them and what they [...]

Posted in Box2D, QuickBox2D, motion | Tagged , , , , | 1 Comment

QuickBox2D Gear Joint

CLICK HERE TO COPY
Actionscript:

import com.actionsnippet.qbox.*;

import Box2D.Common.Math.*;

 

[SWF (backgroundColor=0x000000, width=700, height=600)]

 

var sim:QuickBox2D = new QuickBox2D(this,{gravityY:10});

 

sim.setDefault({fillColor:0x113366, fillAlpha:0.8, lineColor:0x3355AA});

sim.createStageWalls();

 

var boxA:QuickObject = sim.addBox({x:10, y:8, width:4, height:0.5, density:10});

var boxB:QuickObject = sim.addBox({x:5, y:5, density:10});

boxB.body.SetLinearVelocity(new b2Vec2(5, 0));

 

var rev1:QuickObject = sim.addJoint({type:"revolute", a:sim.w.GetGroundBody(), b:boxA.body, anchor:boxA.body.GetWorldCenter()})

           

var rev2:QuickObject = sim.addJoint({type:"prismatic", a:sim.w.GetGroundBody(), axis:new b2Vec2(1, 0), b:boxB.body, anchor:boxB.body.GetWorldCenter()})

            [...]

Posted in Box2D, QuickBox2D, motion | Tagged , , , | 5 Comments

QuickBox2D Connect to GroundBody

CLICK HERE TO COPY
Actionscript:

import com.actionsnippet.qbox.*;

 

[SWF (backgroundColor=0x000000, width=700, height=600)]

 

var sim:QuickBox2D = new QuickBox2D(this);

 

sim.setDefault({fillColor:0x113366, fillAlpha:0.8, lineColor:0x3355AA});

 

sim.createStageWalls();

 

var boxA:QuickObject = sim.addBox({x:10, y:8, width:4, height:0.5, angularDamping:1});

var boxB:QuickObject = sim.addBox({x:7, y:8, width:3, height:0.25, angle:-.5, angularDamping:1});

var boxC:QuickObject = sim.addBox({x:12, y:2, width:2, height:1});

 

var rev:QuickObject = sim.addJoint({type:"revolute", a:boxA.body, b:sim.w.GetGroundBody()});

// add a red dot to boxA

with (boxA.userData.graphics) lineStyle(), beginFill(0xFF0000), drawCircle(0,0,2);

 

var rev2:QuickObject = sim.addJoint({type:"revolute", a:boxB.body, b:sim.w.GetGroundBody()});

with [...]

Posted in Box2D, QuickBox2D, motion | Tagged , , , , | 3 Comments