Bouncing Ball in Scratch

by 1004589 in Design > Game Design

718 Views, 2 Favorites, 0 Comments

Bouncing Ball in Scratch

Screenshot 2026-04-16 135449.png

I made this for the contest

Supplies

https://scratch.mit.edu

Sprite

Screenshot 2026-04-21 130545.png

Create a simple sprite of a ball, it can be a different shape, but for this I am using a ball.

Variables

Screenshot 2026-04-21 130633.png

make these three variables: ambounces (# of bounces to do) bounces (total bounces done) velocity (speed)

Coding 1

Screenshot 2026-04-17 134632.png

after the flag block add a go to block and set that to 0, 120. Then add the set variable to blocks. Set velocity to 1, bounces to 0 and ambounces to the amount of bounces the ball should do (Technically it is how many times the ball touches the floor, so setting it to 1 will just make it fall to the floor.) Also Add a repeat block with the amount of times it repeats set to ambounces

Coding 2

Screenshot 2026-04-17 135416.png

Add a repeat until block inside the repeat block and set it to 'y position < -150' Inside of that add a change y by block and set that to 'velocity * -1' Under that add a change velocity by 1 block. Outside the repeat until block add a set y position to -150 block.

Coding 3

Screenshot 2026-04-20 104349.png

Under the set y to -150 block, but still inside the repeat ambounces block, add a change bounces by 1 block. Underneath that is a very confusing formula. Set Velocity to Velocity * (-0.8 - ((Bounces * -0.015) - ((20 / Ambounce) * 0.06)))

The gist of the formula is kind of hard to explain but here is it in simple terms

  1. Sets velocity to velocity * -0.8 which makes the velocity negative (makes it go up) and smaller (doesn't go up as high)
  2. The second part with the Bounces block makes it so as the bounces go up it gets smaller
  3. The Third part with the Ambounce block makes it so the more bounces the ball should do, the bigger it is
  4. The formula is basically -0.8 - (#1 - #2.) The more bounces the ball does makes #1 more negative, and the lower Ambounce is, it makes #2 more positive.

Example If Velocity is 10, Bounces is 4 and Ambounce is 7. Than it equals 10 * (-0.8 - ((4 * -0.015) - ((20/7) * 0.06) * 0.06))) which equals -5.69

Background

Screenshot 2026-04-21 132434.png

Set a background, this could really be anything but I made mine pretty simple.

Done

That's it. You can change the Ambounce value to get a different simulation, I find that around 6-10 bounces looks the best. You can also change the numbers in the formula to make it look how you want.


https://scratch.mit.edu/projects/1277878978/

Downloads