Section 4 – draw screen and track the score

So, we know that the ball bounces off the top and bottom of the screen as well as off the paddles. However, if the user misses the ball with the paddle, what happens to the ball? What happens to the player and their score?

In this section of the game, we use the location of the x coordinates to determine whether the ball is on the screen or it has gone past the paddles and is outside the screen. We use our if statement to tell the computer what to do. The x axis 0 coordinate is the left-most side of the screen. If the ball's x value is less than 0, then the player on the other side (player 2) has scored a point because player 1 failed to block the ball. If you read the lines of code, you will notice that ...

Get Python Projects for Kids now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.