Falling Sand Game Online

Pour sand, water, and snow — then tilt your phone to flip gravity. A real-time particle physics sandbox that runs entirely in your browser. No install required.

3
8
Mouse/touch: pour particles  |  On mobile: tilt to shift gravity

How it works

Each frame the simulation steps every particle using simple cellular-automaton rules evaluated on a 2-D grid — no physics engine library needed.

Sand Falls straight down. If blocked, slides left or right at random. Piles up naturally and angles of repose emerge.
Water Falls and then spreads laterally in both directions, filling the lowest available space. Flows under sand.
Snow Falls slowly, sticks on contact, and can form drifts. Lighter than sand — floats on water.
Tilt gravity On a phone or tablet the deviceorientation event reports the device tilt angles (beta/gamma). The simulation rotates the gravity vector in real time so particles "fall" toward the low side of the screen.

The grid runs at 80 × 120 cells (scaled to fill the display) so simulation stays fast even on mid-range phones. Cells are drawn via Canvas 2D putImageData for zero-GC pixel blitting.

Frequently asked questions

Does tilt gravity work on desktop?
Tilt uses the DeviceOrientationEvent API which is only available on phones and tablets with a real accelerometer. On a laptop or desktop you control particles with mouse drag instead — click and hold to pour, or click once to place a single brush-full. The simulation still has full gravity; it just stays pointing straight down.
Why do I need to grant motion permission on iPhone?
Since iOS 13, Apple requires a user gesture before a website can read accelerometer data. When you first touch or click the canvas on an iPhone, the game will request DeviceOrientationEvent.requestPermission(). Tap "Allow" in the system prompt and tilt gravity activates immediately. The permission is per-session; no data ever leaves your device.
What are the cellular-automaton rules for each material?
Every tick the grid is scanned from the bottom up (in the direction gravity points). Sand: move to the cell directly below if empty; else try diagonally below-left or below-right chosen randomly. Water: same fall step as sand, but if blocked below also tries to spread two cells left and right (picks a random side first to avoid directional bias). Snow: like sand but with a 60% chance of skipping movement per tick, creating a slow-drift effect. Wall: static, never moves. The gravity direction from the tilt sensor rotates which cells count as "below" and "diagonal-below".