I cannot find my mistake. It should bounce off the paddles and it should restart once it is gameover. Can someone find my mistakes? : So this is my entire code and what it does not do, but should definitely do is first bounce off when colliding with the paddles and second if it does not do so then once the game enters in gameover mode once a key is pressed it should restart the game. Now I've tried several things and nothing seems to work. 

Can someone please find a solution and try to explain what I did wrong?    

    // variables for the ball
    int ball_width = 15, ball_height = 15;  
    int ballX = width/2, ballY = height/2;
    //
    // variables for the paddles
    int paddle_width = 20, paddle_height = 150;
    int paddle1 = 60, paddle2;
    //
    // direction variables
    int directionX = 15, directionY = 15;
    //
    // variables for the score
    int scorecounter = 0;
    //
    //game states
    boolean playing = false, gameover = false, finalscore = false, score = true;

    void setup () {

    size (1900, 1300); // the field game is going to be 1900x1300 px big
    rectMode (CENTER);
    paddle2 = width - 60;
    }



    void draw () {

    background (0); // black background

    playing ();
    gameover ();
    finalscore();

    }

    // 
    void playing () {

    if (keyPressed) { 
    playing = true;
    }

    if (!playing) { // playing = false

    fill(255); 
    textSize(80); 
    textAlign(CENTER); 
    text("Press Space to Play", width/2, height/4);

    fill (255); 
    ellipse (width/2, height/2, ball_width, ball_height); // this is the starting point of the ball
    fill (255, 10, 20); 
    rect(paddle1, (height/2), paddle_width, paddle_height);  // red pong
    fill (60, 255, 0); 
    rect(paddle2, (height/2), paddle_width, paddle_height);  // green pong
    }

    if (playing) { // playing = true

    score();

    ballX = ballX + directionX; 
    ballY = ballY + directionY;

    fill (255); 
    ellipse (ballX, ballY, ball_width, ball_height); 

    fill ( 255, 10, 20 ); 
    rect(paddle1, mouseY, paddle_width, paddle_height); // red pong
    fill ( 60, 255, 0 ); 
    rect(paddle2, mouseY, paddle_width, paddle_height);  // green pong

    if ( ballY > height ) { 
      directionY = -directionY;
    } // if the ball reaches the lower wall it will bounce off
    if ( ballY < 0 ) { 
      directionY = -directionY;
    } // if the ball reaches the upper wall it will bounce off

    if ( ballX > width || ballX < 0 ) { 
      gameover = true; }
    }
  
    if (ballX == paddle1 && ballY <= paddle_height) { 
      directionX = -directionX;
      directionY = -directionY;
    }
    if (ballX == paddle2 && ballY <= paddle_height) {
      directionX = -directionX;
      directionY = -directionY;
    }
    }

    void gameover () {
  
    if (gameover) {
    background (0);
    }

    finalscore ();
    score = false;

    if (keyPressed) { 
    playing = true;
    }
    }

    void score () {

    if (playing) {

    fill(255); 
    textSize(45); 
    textAlign(CENTER); 
    text ( scorecounter, width/2, height/4);

    if (ballX == paddle1 && ballY <= paddle_height) { 
      scorecounter = scorecounter + 10;
    }
    if (ballX == paddle2 && ballX <= paddle_height) { 
      scorecounter = scorecounter + 10;
    }
    }

    if (!playing) {
    score = false;
    }
    }

    void finalscore () {

    if (gameover) {

    score = false;

    fill(255); 
    textSize(45); 
    textAlign(CENTER); 
    text("Game Over. Press a key to play again.", width/2, height/4);
    fill(255); 
    textSize(80); 
    textAlign(CENTER); 
    text("You scored " + scorecounter + " points", width/2, (height/4) * 3);
   
    
    if (keyPressed) { 
       playing = playing;
    }
    }
    }  



