I'm drawing a stick figure in OpenGL and I have the body (which I'm using GL_LINES
for) and the head (which I'm using GL_LINE_LOOP
for). After drawing these out, they all show up perfectly fine. However, when I go to move the stick figure all over the screen, the head disconnects from the body. I need these to stay as one for game purposes. Can anyone help me out and explain it as well?
If you need me to explain further as well, just let me know.
//Drawing body
glBegin(GL_LINES);
glColor3f(1,1,1);
glVertex2f(xpos, ypos);
glVertex2f(xpos - xdim/2, ypos - ydim);
glVertex2f(xpos, ypos);
glVertex2f(xpos + xdim/2, ypos - ydim);
glVertex2f(xpos, ypos);
glVertex2f(xpos, ypos + ydim);
glVertex2f(xpos - xdim/2, ypos + ydim/2);
glVertex2f(xpos, ypos + ydim);
glVertex2f(xpos - xdim/2, ypos + ydim/2);
glVertex2f(xpos - xdim/4, ypos + ydim/2);
glVertex2f(xpos - xdim/4, ypos + ydim/2);
glVertex2f(xpos - xdim/4, ypos + ydim/3);
glVertex2f(xpos - xdim/4, ypos + ydim/2);
glVertex2f(xpos + xdim, ypos + ydim/2);
glVertex2f(xpos + xdim, ypos + ydim/2);
glVertex2f(xpos + xdim, ypos + ydim/3);
glVertex2f(xpos + xdim, ypos + ydim/2);
glVertex2f(xpos + xdim + xdim/2, ypos + ydim/2);
glVertex2f(xpos + xdim/2, ypos + ydim/2);
glVertex2f(xpos, ypos + ydim);
glVertex2f(xpos, ypos + ydim + ydim/4);
glVertex2f(xpos, ypos + ydim);
glEnd();
//Drawing head
glBegin(GL_LINE_LOOP);
glColor3f(1,1,1);
for (i = 0; i < 100; i++){
j = 2*3.14*i/100;
glVertex2f(200 + 15 * cos(j), 254 + 15 * sin(j));
}
glEnd();