Creating a catchy game with Scratch coding starts with everyone’s favorite sprite: a ball. Whether on a beach or tennis court, in real life or the virtual one, pitching, catching, throwing, blocking, or rolling this round object, brings us joy! So, we’ve decided to show you how to make a quick, painless, (and possibly addictive), Ball Bounce game in Scratch! By the way, we also have a special fun Scratch snowball game class right now for the holidays.
How to make a ball bounce in Scratch
It is so easy…anybody can do it. Seriously! All that’s needed is a connection to the Scratch website along with this tutorial and voila! – you’ve got yourself a custom ball bounce game. Let's get started.
1. Go to Scratch
Don’t have a Scratch account? Don’t worry. You can still create the Ball Bounce game without one. Just click on Create tab at the top of the home page, and within seconds, you’ll be in the code builder where all the magic happens:
2. Eliminate Scratch Mascot/Add Ball Sprite
We won’t need the default Sprite so feel free to hit the trash-can icon to the right of the Sprite and below the canvas, to delete the cat. Instead, we’ll dip into the Library where we’ll select the first ball we see:
3. Make the Ball Bounce
Just like with most games, we know there are many ways a ball can bounce. For example, when dropped to the ground, thrown against a wall, hit with a racket, slapped, kicked, etc. Apart from a bowling or a wrecking ball, we know that there are many ways to physically make the ball bounce. However, one question remains: at want point of the game do we want to see our ball bounce?
Same applies here. So, let’s use the “when this sprite clicked” to get the event going, and then we’ll find the furthest point on the right/left, on the screen, and make the ball travel back and forth to depict a bounce:
And just like that, our ball became a little more alive. All there’s left to do is explore a few more ways we can program our ball to bounce.
How to make a ball bounce randomly
So far, we have programmed our Ball Sprite to move from one end of the screen to the other. Although we made it appear like it’s bouncing, it is only doing it from left to right.
Customize the ball to make it bounce off all four “walls”
What if we wanted to see our ball bouncing off all possible ends of the canvas? Luckily, Scratch offers an easy solution for that, so all there’s left to do is apply logic. For example, Scratch already has a block that we can use to make it bounce. It is even spelt out for us “if on edge, bounce”. So think no further and use it right away.
Customize the ball to make it bounce off another Sprite
What if we happen to have another Sprite in the same game and the expectations are for the ball to bounce off that Sprite as well, to make the game more real? This too is easily attainable.
Let’s bring out Nano – a dummy sprite without any function—to use as a stepping stone (or in our case, “bouncing stone”). But first, keep in mind that we would need to use some sort of a condition in order to make that happen. Let’s put it in words before we tackle the blocks: “If our ball collides with Nano, then do what?”. How about changing the path to the exact opposite direction from the Ball/Sprite collision? Hence the saying “A 180-degree change”:
Use another Sprite, such as Paddle, to control the bounce
Perhaps we want our game to seem like we were playing ping-pong or tennis, where we can control the ball with a Sprite like Paddle, to prevent the ball from falling to the side lines.
Let’s first have a clear understanding of how and why the Paddle Sprite is used in this game: its indefinite position will be at the bottom of the screen so it will never go up or down. Since its main purpose is to prevent the ball from touching the bottom of the screen, the Paddle Sprite will only move left and right, as we anticipate its fall. The other idea is to have the ball bounce off the Paddle Sprite, and much like with Nano, so we’ll use the same logic there:
Now you know how to make a ball bounce in Scratch
In this tutorial, we have simplified the way a ball bounce game can be created in Scratch. Here's the whole project. We first showed you how to make the ball bounce off all four walls by using “if on edge, bounce” block. Then we shared a hint on how the same logic can be applied, using control and motion blocks, to make the ball bounce off Spites as well. To make our ball bounce game even more catchy, we added a touch of interactive logic to allow players to partake in controlling the ball.
This tutorial reveals that programming a ball bounce game doesn’t have to be complicated, hence why you now know how to make a ball bounce even beyond edge.
And if you would like to learn more clever ways to build games like this, check out how to make a scrolling game on Scratch. Maybe you are still new to Scratch and would like to expand your horizons, enroll in one of Scratch coding for kids classes and receive the best Scratch training of all!
Written by Sandra Dizdarevic, a Create & Learn instructor with 6 years of experience teaching STEM to children in the 3rd through 11th grade. She has an Undergraduate as well as a Masters Degree in Management Information Systems from UNO.