Let's begin this part by modifying the behavior of the ball. We'll also create a variable to keep track of the player's score and add a code block to add a point each time the player hits the ball. Here's the second code stack for the ball:
"Soften" the Bounce of the Ball from the Paddle
Let's add a tiny pause in the ball's movement after being hit with the paddle. We'll also add a bit of randomness to its direction, coming off the paddle, as if some spin were imparted to it when it was hit.
-
From the left, in the Control group, select the wait ( 1 ) seconds code block.
- Drag it to a position below the turn ( 180 ) degrees code block.
-
Click the number 1 and change it to .5 seconds.
Add Some Random Movement to the Ball
When the ball hits your paddle, it bounces away on the exact reciprocal of its direction when it struck the paddle. We can easily make these bounces more random and make the game more interesting.
- From the left, in the Operators group, choose the pick random ( 1 ) to ( 10 ) code block.
- Drag and drop the new code block onto the turn ( 180 ) degrees code block.
-
Click the two numbers and change them to two numbers on either side of 180. The wider the separation between the two numbers, the more
random the ball's motion will be.