All examples · Physics

Bumpers

What this example shows

The same physics as Falling crates, written by hand instead of read from a file. Press SPACE to push the ball back up. The blue band is a sensor: it notices the ball and does not stop it, which is what a checkpoint, a pickup and a damage zone all are.

The interesting part is where the two halves meet. usePhysicsWorld2d and usePhysicsBody2d belong to the engine: they say how hard things fall and what each object is made of, write it into the scene so it can be saved, and hand it to whatever is installed to simulate. Everything past that is the adapter's, through getPhysicsWorld2d(): a push, a speed, a contact. The format can say what a thing is, never what happens to it.

What you see is not what collides. Every picture is a plain block, because that is all a tinted sprite is, while the ball and the three pegs collide as circles. Lining up the collider with the art is the game author's business, not the engine's.

Starting