06.23 · 3D & Advanced

2D Physics

Balls drop where you click, bounce and pile up. Best for playful intros.

Click it

Click or tap anywhere in the box to drop a ball, drag a ball to throw it, or press Show me.

Try it

Change a setting, then drop a few balls or press Show me.

Gravity

How hard the balls are pulled down; on the Moon they float.

Bounciness

How much of its speed a ball keeps after each bounce.

Ball sizes

Mixed sizes pack into a looser, bumpier pile.

More optionsFewer options

An arrow on each moving ball shows how fast it goes, and where.

Copy the prompt

Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.

Add a box of bouncing balls to [the hero or empty area you want to liven up]. A click or tap drops a ball there; it falls, bounces off the walls and each other, and comes to rest in a pile. Dragging a ball with the pointer or a finger picks it up, and letting go throws it at the speed of the drag. Run the physics in fixed steps, as many as the time since the last frame needs, so it behaves the same on every screen, and stop drawing once everything is still. Fade out the oldest ball when there are too many. If the visitor has reduced motion turned on, show each new ball already resting where it would land. Match the settings listed below.

Replace the words in brackets with your own element. Your settings are added at the end.

Free and open source. If this helped, a star on GitHub helps other people find it.

Star on GitHub

What it is

The full explanation is in README.md.

Good for

  • Playful intros
  • Empty states
  • Games and toys
  • Kids' and learning sites

Avoid on

  • Forms and checkout
  • Serious content