I cannot figure out what is wrong with this collision detection code.
ballx1 and bally1 is the current position for the ball
ballx2 and bally2 is the position of the ball one step before
paddlex1 and paddley1 is the current position of the paddle
diry is the direction of the ball in the y axis
I am trying to check all the positions from the step before and the current step for a collision to avoid the ball jumping over the paddle.
Right now the ball just passes right over the paddle and I cannot figure out why.

a = 0;
while (a <= bally1 - bally2){
            if (ballx1 >= paddlex1 - 40 && ballx1 <= paddlex1 + 40 && bally2 + a >= paddley1 + 10 && bally2 + a <= paddley1 - 10){diry = diry * -1;}
            a = a + 1;
        }

Is this for a tradition pong game, where the paddle could only have
1 x coordinate and move only up or down?