Back to Physics in Simulations
BeginnerChildren

Gravity and Bouncing Balls

Why does a ball fall back to the ground when you throw it up? Gravity!

Gravity is a force that pulls objects toward each other. Earth has a lot of mass, so it has strong gravity that pulls everything down.

When a ball hits the ground, the energy from the fall has to go somewhere. The ball squishes a little and then pushes back, which makes it bounce! With each bounce, it loses a little energy, so it doesn't bounce as high as before.

We can simulate this in code by having a 'velocity' for our ball. Gravity constantly adds to the downward velocity. When it hits the ground, we reverse the velocity but make it a little weaker.

Simulate a Bouncing Ball

Simulate a ball bouncing 5 times, reducing its height by half each time. The initial height is 100.