Making the Ball Move
The instructions that make the ball move also go inside the
while loop, so they are all indented by four spaces, except where they need to be indented further. You need to insert them where indicated by a comment in the previous chunk of code.
We start by storing the current position of the ball in the variables
oldbally. Then we check for whether we need to bounce off the left, right, or top wall. If the ball’s X position is
1, for example, it can’t go any further left, so we change its horizontal direction to be to the right by giving
ballxdir a value of
1. If the ball is in the top row, its Y direction is changed to downwards.
# uncomment below for cheat mode
# if bally==BATY-1:
The next thing we need to do is check whether the ball has hit the bat, or fallen out of play. First we check whether the ball is on the row above the ball, which is BATY-1. If it is, we check whether it’s hit the bat. There are two ways ...