Boxed Physics is an extension that allows you to use 2D physics simulations in your projects.
This documentation will guide you through the process of using Boxed Physics.
When using the Boxed Physics extension, you always need to initialise the environment when starting the project. to do this, you can use the Init World, scale 1m: [SCALE] gravity: [GRAVITY] scene: [SCENE]
block.
Scene is the type of containment to keep objects within the stage:
You can move forward in time using the step simulation block. Run this in a loop to keep the physics going.
This next block lets you set the physics options. You usually won't need to use this block.
You can also set the speed of the world with the set slow motion block.
You can also get the slow motion value with the get slow motion block.
Making objects requires that you define an object first, so running this does nothing on its own.
Define an object type first, then the object itself. Now, you can place it in the world.
You can do the steps in any order, just Create the object body last.
Remember to run the [Create body] block after defining the object
Types allow you to make objects with spesific properties.
Making a box is simple, just define the box, then create the body.
Making a circle is just as simple, Use the code from the box, and replace it with the circle making block.
Thare are two ways of making a pollygon object. You can eather use the Define pollygon as this costume
block, or the Define Polygon, points: [POINTS]
block.
Define pollygon as this costume
lets you use the costume of a sprite to make a pollygon, while
Define Polygon, points: [POINTS]
lets you defide a pollygon manually.
Every point in a pollygon is seperated by 3 spaces. Every point has only one space from x to y.
You can destroy an object by simply providing its name into the destroy block.
You can make objects not collide with eachother using collision layers.
Using the Set object [NAME] to be on collision layer [LAYERS]
block, you can st objects to be on any layer you want.
Each layer is like a diferent world. Objects on that layer will collide with eachother, but not collide with other layers.
Note: Only objects on layer 1 will collide with the scene edges.
You can also allow objects to be on more than one layer at once by seperating layers with a space.
You can set the damping or the rotational damping of an object.
Thare are a two ways to move your objects. you can push them, or you can set their movement directly.
You can push your objects using inpulses, or World Impulses.
You can also set the velocity of an object directly, or remove it entirely.
While I'm at it, I might as well mention these blocks
You can get the attributes of any object using the (get [thing] from [object])
block.
You can get the following from an object:
You can also get an object under any position with this:
Joints are another thing built into Boxed Physics. Just like objects, they need to be defined before you can place them.
Thare are Rotating, Spring, Weld, Slider, and Mouse jonts built into Boxed Physics, but more are on the way.
Thare are only two joints that need extra info to define them, being springs and sliders.
Springs are made of three values: Length, Damping, and Frequency.
Sliders are another type of joint is a slider joint. Sliders are made with a direction, lower stop, and an upper stop.
You can edit joints using the Set [attr] of [joint]
block to set attributes of joints.
You can set the following:
Getting joint attributes is just as easy.
You can also delete joints.
If you made a mouse joint, you can edit the target position with this block.
Want more scripting examples? Go here.