private static void logic(int delta) {
        ball.update(delta);
        bat.update(delta);

        for (Brick brick : bricks) {
            if (ball.intersects(brick)) {
                ball.setDY(Math.abs(ball.getDY()));
                brick.setUsed(false);
                brick.setX(0);
                brick.setY(0);
            }
        }
        //ball.getX() >= bat.getX() && ball.getY() >= bat.getY()
        //ball hit the bat
        if (ball.intersects(bat)) {

            ball.setDY(-Math.abs(ball.getDY()));
            ball.setDX(-Math.abs(ball.getDX())+0.1/3);


            ball.setDX(Math.abs(ball.getDX()));
            Random ran = new Random();
            ball.setDX(ball.getDX() + bat.getDX() / 3 + (double) (1 - ran.nextInt(2)) / 200);

        }

        //Top Bound
        if (ball.getY() < 0) {
            ball.setDY(-ball.getDY());
        }

        //left
        if (ball.getX() <= 0) {
            ball.setDX(Math.abs(ball.getDX()));
            Random ran = new Random();
            ball.setDX(ball.getDX() + bat.getDX() / 3 + (double) (1 - ran.nextInt(2)) / 200);
        }

        //right
        if (ball.getX() > WIDTH){
            ball.setDX(-ball.getDX());
        }
        //ball.getY() > HEIGHT - ball.getHeight()

        //bottom
        if (ball.getY() > HEIGHT) {
            //reset game
            setUpEntities();
        }

        //fix DY if DY is too large
        //if (Math.abs(ball.getDY()) > Math.abs(ball.getDX() * 1.5)) {
        //  ball.setDY(ball.getDY() / 1.5);
        //}

    }