From a2e7fff352a39fddc6c4340924006a6310fdb339 Mon Sep 17 00:00:00 2001 From: DNin01 <106490990+DNin01@users.noreply.github.com> Date: Sun, 4 Jun 2023 17:35:57 -0700 Subject: [PATCH 1/2] Add documentation for Box2D extension --- extensions/box2d.js | 1 + website/box2d.html | 206 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 207 insertions(+) create mode 100644 website/box2d.html diff --git a/extensions/box2d.js b/extensions/box2d.js index eac937043d..fb53f329d5 100644 --- a/extensions/box2d.js +++ b/extensions/box2d.js @@ -12354,6 +12354,7 @@ default: "Physics", description: "Label for the Griffpatch extension category", }), + docsURI: "https://extensions.turbowarp.org/box2d.html", menuIconURI: menuIconURI, blockIconURI: blockIconURI, blocks: [ diff --git a/website/box2d.html b/website/box2d.html new file mode 100644 index 0000000000..90fb6e1c99 --- /dev/null +++ b/website/box2d.html @@ -0,0 +1,206 @@ + + + + + + Box2D docs + + + + + + + +
+ Box2D extension documentation +
+
+

About this extension

+ + +

Blocks

+ +

World

+

Adjust the physics of all sprites.

+ +
setupstageboxed stage
+

Choose a type of containment to keep sprites within the stage.

+ + +
+ +
setgravitytox:0y:-10
+

Change the direction and strength of gravity.

+ +
+ +
stepsimulation
+

Move forward in time by one step. Run this in a loop to keep the physics going.

+ +

Sprites

+

Manipulate individual sprites.

+ +
enableforthis costumemodenormal
+

Make physics apply to this sprite. It can also collide with other sprites that have physics enabled.

+ + +

Precision mode will make the sprite work extra hard to make sure it doesn't overlap with anything. Note that this can decrease performance and even cause the project to get stuck, so use with care.

+ +
+ +
gotox:0y:0in world
+

Make the sprite go to the specified location.

+ + + +
+ +
setvelocitytosx:0sy:0
+

Set the velocity (speed) of the sprite to the specified value.

+ +

You can get the velocity of the current sprite with the (x velocity) and (y velocity) reporters.

+ +
+ +
pushwithforce25indirection0
+

Directly send the sprite flying in a certain direction, adding on to its current velocity.

+ +
+ +
setangularvelocityto30
+

Set the angular velocity (rotational speed) of the sprite to the specified value.

+ +

You can get the angular velocity of the current sprite with the (angular velocity) reporter.

+ +
+ +
spinwithforce500
+

Directly send the sprite spinning, adding on to its current angular (rotational) velocity.

+ +
+ +
setfixedfixed in place
+

Choose whether the sprite is fixed in place or can move around.

+ +

You can tell if the sprite is currently fixed in place with the (fixed?) reporter.

+ +
+ +
setdensitynormal
+

Set the sprite's density, which affects how heavy it is.

+ +

You can get the sprite's current density with the (density) reporter.

+ +
+ +
setfrictionnormal
+

Set the sprite's roughness. Smoother settings make the sprite slipperier.

+ +

You can get the sprite's current friction with the (friction) reporter.

+ +
+ +
setbouncenormal
+

Set the sprite's bounciness.

+ +

You can get the sprite's current bounciness with the (bounce) reporter.

+ +
+ +
touchingany
+

Returns what other sprites the sprite is touching. Also includes the edges of the stage.

+ +

If there are multiple sprites touching, it will return a comma-separated list of them.

+ +

Screen

+

Move the camera around the world.

+ +
setscrollx:0y:0
+

Scroll to the desired location.

+ +

You can get the current screen position with the (x scroll) and (y scroll) reporters.

+ +

This will not affect the world boundaries set by the [setup stage] block.

+ +

Example

+ +
whenclickedsetupstageboxed stagesetgravitytox:0y:-10createcloneofmyselfrepeat20stepsimulationcreatecloneofmyselfforeverstepsimulationwhenIstartasacloneshowenableforthis costumemodenormalgotox:-150y:240in worldsetbouncequite bouncysetangularvelocityto-4.1
+ +

Credits

+

The block SVGs were generated with scratchblocks.

+
+ + From 1ea8b32ffaf5b9c0734e8bcf99f30998bc21c6a5 Mon Sep 17 00:00:00 2001 From: DNin01 <106490990+DNin01@users.noreply.github.com> Date: Sun, 4 Jun 2023 17:39:31 -0700 Subject: [PATCH 2/2] Box2D **Physics** --- website/box2d.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/box2d.html b/website/box2d.html index 90fb6e1c99..c470d09bbc 100644 --- a/website/box2d.html +++ b/website/box2d.html @@ -3,7 +3,7 @@ - Box2D docs + Box2D Physics docs