title: Need help in Bowling Game in OpenGL C++
body: <p>I am creating a bowling game in openGL C++.</p>
  
  <p>What I have done so far that I have drawn a bowl and three points(obstacles).</p>
  
  <p>The bowl is moved upon key-pressed. </p>
  
  <p>I want to make illusion that <strong>when the bowl hits those obstacles, they should be dropped.</strong> To do this, I have code like <strong>when the X and Y co-ordinates of the ball and of those obstacles are same, then the obstacle's X and Y co-ordinates are incremented to make illusion that they are dropped.</strong></p>
  
  <p>Suggest some logic.</p>
  
  <p>This is my code: -</p>
  
  <pre><code>    #include &lt;GL/glut.h&gt;
      #include &lt;cmath&gt;
      #include &lt;stdio.h&gt;
      float posX = 0.01, posY = -0.1, posZ = 0,
  
      bx1 = 0.01, by1 = 0.1,
      bx2 = 0.06, by2 = 0.1,
      bx3 = 0.10, by3 = 0.1;
  
      GLfloat rotation = 90.0;
      double x, y, angle;
      #define PI 3.1415926535898
      GLint circle_points = 50;
  
      void bottle() {
          glColor3f(0.0, 0.0, 1.0);
          glPointSize(9.0);
          glBegin(GL_POINTS);
          glVertex3f(bx1, by1, 0.0);
          glEnd();
  
          glBegin(GL_POINTS);
          glVertex3f(bx2, by2, 0.0);
  
          glEnd();
          glBegin(GL_POINTS);
          glVertex3f(bx3, by3, 0.0);
  
          glEnd();
  
          glFlush();
  
      }
  
      void circ() {
          glColor3f(0.0, 0.0, 1.0);
          glBegin(GL_TRIANGLE_FAN);
          for (int i = 0; i &lt;= 300; i++) {
              angle = 2 * PI * i / 300;
              x = cos(angle) / 20;
              y = sin(angle) / 20;
              glVertex2d(x, y);
          }
          glEnd();
      }
  
      void display() {
          glClearColor(1.0, 1.0, 1.0, 0.0);
          glClear(GL_COLOR_BUFFER_BIT);
  
          glMatrixMode(GL_PROJECTION);
          glLoadIdentity();
          gluOrtho2D(-1.0, 1.0, -1.0, 1.0);
  
          glMatrixMode(GL_MODELVIEW);
          glLoadIdentity();
  
          glPushMatrix();
          bottle();
          glPopMatrix();
  
          glPushMatrix();
          glTranslatef(posX, posY, posZ);
          circ();
          glPopMatrix();
      glutSwapBuffers();
  }
  
  float move_unit = 0.02f;
  void keyboardown(int key, int x, int y) {
      switch (key) {
      case GLUT_KEY_RIGHT:
          posX += move_unit;
          break;
      case GLUT_KEY_LEFT:
          posX -= move_unit;
          break;
      case GLUT_KEY_UP:
          posY += move_unit;
          break;
      case GLUT_KEY_DOWN:
          posY -= move_unit;
          break;
      default:
          break;
      }
      if ( posX == bx1 || posX == bx2  ) {
  
          bx1 -= 0.02,by1 += 0.06;
          bx2 = 0.02,
          by2 += 0.08;
          bx3 = 0.04,
          by3 += 0.04;
  
      }
  
      glutPostRedisplay();
  }
  
  int main(int argc, char** argv) {
      glutInit(&amp;argc, argv);
      glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
      glutInitWindowSize(600, 500);
      glutInitWindowPosition(0, 0);
      glutCreateWindow("Practice 1");
      glutDisplayFunc(display);
      glutSpecialFunc(keyboardown);
      glutMainLoop();
  }
  </code></pre>