why gun trajectory did not follow correct path and How can we acheive correct path ?

I am making 3d game in open gl whcih contain pendulums and cannon guns shoot by user but when i shoot the bullet did not follow correct path and thats why collision detection did not occure for simplicity initialy there is gun with bullet and only single pendulum bob as scene in picture
pendulum code is here

 glPushMatrix();
    glTranslatef(400, 50, -400);
    drawBomb();
    glPopMatrix();

cannon gun and bullet code is here

//canon fire with bomb

glPushMatrix();
    glTranslatef(600, 0, -400);
    glRotatef(-longFire, 1, 0, 0);
    glRotatef(-longFireChaw, 0, 1, 0);

    //glTranslatef(0, 0, -25);
    drawFireHolder();
    //printf_s("Long fire is %d", longFire);

    glPopMatrix();

    glPushMatrix();

    glTranslatef(bombX, bombY, -400);
    //glRotatef(-longFire, xRotate, yRotate, zRotate);
    glRotatef(-longFire, 1, 0, 0);
    glRotatef(-longFireChaw, 0, 1, 0);
    //glRotatef(longFire, 0, 1, 0);
    glTranslatef(0, 0, bombZ);
    glTranslatef(0, 0, 25);

    drawBomb();
    glPopMatrix();

timer code is here


if (fire == true)
    {

        bx = 0;
        bz = 415-bombX;
        dx = 400 - bombX;
        dy = 50-bombY;
        dz = -400 -(-400);

        float distance = sqrt(dx*dx + dy*dy + dz*dz);

    //  printf("DISTANCE IS %f",distance);
    //  distance=floor(distance);
        if (distance <=100)
        {
            printf("Collision Occur");
        }
        if (distance <= (12))// radius is the radus of our bounding sphere for each object
        {
        //  printf("Collision Occur");
        }

        //bombX++;
        bombX--;
        bombY = bombY +sin((longFire*3.142)/180);
        //bombZ = bombZ + cos((longFire*3.142) / 180);
        bombZ++;
        //printf("Y IS %f",bombY);
    }

keboard controller is here


if (key == 't' || key == 'T')
    {
        xRotate = 1, yRotate = 0, zRotate = 0;
        longFire += 5;
        handlerMove();
    }
    if (key == 'e' || key == 'E')
    {
        xRotate = 1, yRotate = 0, zRotate = 0;
        longFire -= 5;
        handlerMove();
    }
    if (key == 'r' || key == 'R')
    {
        xRotate = 0, yRotate = 1, zRotate = 0;
        longFireChaw += 5;
        handlerMove();
    }
    if (key == 'w' || key == 'W')
    {
        xRotate = 0, yRotate = 1, zRotate = 0;
        longFireChaw -= 5;
        handlerMove();
    }

how can we follow correct path and hit pendulum any idea?