Posted on

Scratch Coding – Video Ball Bounce

This is a game that will have the player use video motion to keep the balls from hitting the moving paddle.


We need to create two sprites, we are going to have some falling balls and a moving paddle.

Dropping Balls

We would like our balls to drop from the top of the screen, before we start the ball dropping, we are going to set the background as the video feed.

We then need to hide the ball, so that when we start as a clone we can show it again. We need to create clones that will start falling every few seconds. We always want our balls to be created so we are going to use a forever loop.

When our ball starts as a clone, the first thing we want to do is show the sprite. The next thing we do is move the cloned sprite to a random position where it can fall. We make the ball start on the Y position to 160 so that it doesn’t start by touching the edge.

The next thing we are going to do is make the balls fall from the top.

If we touch the edge of the of the screen, we need to delete the clone.

If we test this, we will see that the balls fall from the sky and then are deleted when they hit the edge.

Moving Paddles

The green paddle is going to move across the screen, when it hits the edge we will get it to move back the other way.

Video Bounce

Back on our ball sprite, we need to test to see if the video has some fast moving parts to it. We have a special block that we can use to test the speed of the video.

This makes the ball bounce back up and will touch the top of the screen which will delete the cloned ball.

Keeping Score

We need to add a new variable called ‘lives’, on our ball sprite, we want to set this to 5 lives to start with. Our code will look like:

We then also test to see if the lives are zero, if we have run out of lives we end the program.

We also need to test to see if the ball hits the paddle and if it does then we subtract a life. The full code looks like: