From the Code Shop: Sticky Block Collisions

Sticky blocks were perhaps the trickiest element to implement in Blockwick 2, especially considering our desire for “pixel-perfect” collisions. Here is a quick breakdown of how we pulled them off.

sticky block

First build a hierarchal array of blocks. Then move each dynamic block towards its goal (with a lag if not root block). Then collide each dynamic block against static colliders. Each block that collides with static collider is flagged and locked from moving in that direction. Then collide dynamics blocks against each other causing any lock flags to propagate. Each collider’s lock flags expire after a few physics steps using simple bitwise operations.

Pros: Stable simulations in most cases. Fairly efficient for pixel perfect collisions. Cons: Rounded corner collisions are not handled very well. No rotations.