Skip to content

Demos ​

Each example is an ordinary C++ program and Scene.yml file in the repository. Build visual demos with -DFX2D_BUILD_EXAMPLES=ON, then run binaries from the repository root so asset paths resolve.

bash
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DFX2D_BUILD_EXAMPLES=ON
cmake --build build -j
./build/example_angry_boxes

Targets: example_playground, example_angry_boxes, example_truck, example_stacked_boxes, example_joint_control, example_chain_terrain, example_bucket_fill.

The playground runs in the browser with nothing to build: drag bodies, spawn shapes, reset.

Angry boxes: a slingshot ball knocks over a tower in Fx2D

Angry boxes

Drag the ball, release, topple the tower. Mouse input, a trajectory preview drawn through the renderer's draw callback, impact strength read from scene.contacts(), and a reset callback that re-arms the slingshot. The same mechanic runs headlessly in tests/test_slingshot.cpp.

A truck drives over a physics scene

Truck

A wheeled vehicle that brings suspension, constraints, collision, and textured rendering together. Ships with a headless variant that steps the same scene with no window.

Boxes stack and collide in Fx2D

Stacked boxes

Basic rigid bodies, textured shapes, gravity, resting stability, and friction. The scene the resting-stability tests are modelled on.

Joint control simulation in Fx2D

Joint control

Revolute and prismatic motors in position, velocity, and effort control modes with PID tuning. See the joints guide.

Balls dropped onto polyline terrain in Fx2D

Chain terrain

Open polyline terrain authored as one chain entity, click-to-spawn bodies at runtime, and one-sided chain contacts with ghost-vertex handling so balls roll smoothly across segment joins.

Hundreds of bodies pour into a bucket in Fx2D

Bucket fill

Hundreds of bodies piling into a container: the broad phase, contact cache, and sleeping under load. The adversarial test suite runs the same spawn pattern headlessly.

For a renderer-free loop suited to testing, simulations, and data collection, see headless mode.

Released under the BSD-3-Clause License.